I just can’t seem to get my RJS template to work.
I have this in my .rhtml file:
<%= link_to_remote( “1”, {:url => { :controller => “log”, :action =>
“rate”, :id => post.id, :rating => 1}}, :class => ‘one-star’, :name =>
‘Rate this post 1 star out of 3’) %>
My rate.rjs has this (for testing purposes):
page.alert(‘RJS works!’)
That doesn’t that a thing.
So I added this to my .rhtml file:
<%= link_to_remote( “3”, {:url => { :controller => “log”, :action =>
“rate”, :id => post.id, :rating => 3},
:complete=>‘alert(request.responseText)’}, :class => ‘three-stars’,
:name => ‘Rate this post 3 star out of 3’) %>
Now I get a popup saying:
alert(‘RJS Works!’) instead of actually doing the alert.
end
I prefer this style myself. RJS templates are more about logic and
functionality, so it makes sense to put them in the controller. The
one exception for me would be a template that I might use in several
different controllers.