I have moved!
My new blog is at lindsaar.net
All the old content will stay here though. But check out the new blog
¿ 19/6/2007 - Selecting a different RJS file to display in Ruby on Rails
Sometimes you have a many tasks that send some data to a server, and all of them result in the same line in the same list being updated.
Instead of making several method_name.rjs files, make one called update.rjs, and then add an empty method to your controller called "update"
Then at the end of each of the methods that need to update the record, do the following:
render => { :action => :update }
That way you can keep your views directory clutter free.
An example would be:
def up
@item = Item.find(params[:id])
@item.move_higher
do_list
render :action => 'update'
end
def down
@item = Item.find(params[:id])
@item.move_lower
do_list
render :action => 'update'
end
def top
@item = Item.find(params[:id])
@item.move_to_top
do_list
render :action => 'update'
end
def bottom
@item = Item.find(params[:id])
@item.move_to_bottom
do_list
render :action => 'update'
end
def update
end
end
page.replace_html active_scaffold_content_id, :partial => "list"
|
Post A Comment! :: Send to a Friend!
|
|
|
|
About Me
AKA Raasdnil, this site is about web coding, hosting and all other matters that relate to this... especially Ruby on Rails!
Links
|
|