Forum: Ruby on Rails RJS and variables help...

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
B0be4bfef5a22697a0f44f4fe295aaef?d=identicon&s=25 James Whittaker (aftershock)
on 2006-03-30 14:28
How can I get mt RJS template to accept a variable as the ID value?

Doing this works:
page.replace_html '1', "some text..."

This does not:

page.replace_html @employee.id, "some text..."

Looked and searched but little documentation at the mo especially in
RDocs.
8d30b78dcd3ae8ff8d5e6085059060c7?d=identicon&s=25 Martin Bernd Schmeil (thebernd)
on 2006-03-30 15:24
Not sure, since I didn't test this, but may this be a class mismatch
error? Can you try adding .to_s to your variable?

- Bernd
54077fb03c95861af85880218cf7aef2?d=identicon&s=25 Gokhan Arli (sylow)
on 2006-03-30 18:03
They are ordinary views

lets assume you have @employee in your action then you can use @employee
in your rjs

#Controller
def show
   @user = User.find(params[:id])
end


#show.rjs
page.replace_html "user_#{@user.id}", "You know where to find me"


Gokhan Arli
Web Developer
www.sylow.net
This topic is locked and can not be replied to.