rubyonrailsin

A Ruby and Rails talk

Wednesday, March 31, 2010


[Rails] Re: Ruby in javascript

by rubyonrailsin 0 comments

Tag


Share this post:
Design Float
StumbleUpon
Reddit

Hemant Bhargava wrote:
> Hey Champs..
>
> Can we write some ruby code into javascript ?
>
> Can you guys light me?

you can make a main_scripts.js.erb inside one of your views

then you can mix in ruby and JS together. The ruby will be processed
first, and then made into a static js file, then you can include that.
OR, you can do inline JS in your views (it's yucky though :p ). You
could also get crazy and include the Johnson gem and then get some crazy
ruby generating JS on the fly stuff.

Good luck!

~Jeremy
--
Posted via http://www.ruby-forum.com/.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

No comments:

Post a Comment

Subscribe feeds via e-mail

Blog Archive