[Ruby] JavaScript in FormHelpers

Michael Judge mjudge at surveycomplete.com
Tue Nov 21 10:54:16 PST 2006


> <%= radio_button("post", "category", "rails", options =
> {:onclick=>"javascript:redirect('QueryA1R1.rhtml')"}%>

That works as well because you're assigning the hash to a local  
variable called "options", then the assignment returns the value set  
to it.

Effectively, it's the same as:

<% options = {:onclick => "javascript:redirect('QueryA1R1.rhtml'" } %>
<%= radio_button "post", "category", "rails", options %>

> Amazingly I could not find one single example on the Internet or in  
> my Rails
> books, even the beta Agile Web Development with Rails.  I guess  
> that's one
> of the drawbacks of new technologies.  Most of the Rails books seem  
> very
> introductory and light on Rails, heavy on Ruby. The Agile books  
> seems to be
> the best so far.  I printed the entire pdf.

I've been working with ruby and rails every day for the past year and  
still find huge gaps in my knowledge.  The best thing I can recommend  
is to re-read the agile books every three months.  Sometimes as  
little as a single paragraph, skimmed on an earlier reading, can  
click and be incredibly useful from then on.

It was just last week that I discovered .is_blank? for Objects.   
That's one value packed little test, and I had no idea it existed.

- Mike

On Nov 20, 2006, at 4:49 PM, Neil Moomey wrote:

> Thanks Tom!  That worked!  You had one minor typo which was an  
> extra ) at
> the end so it should look like this:
>
> <%= radio_button("post", "category", "rails",
> {:onclick=>"javascript:redirect('QueryA1R1.rhtml')"}%>
>
> and this seems to work as well:
>
> <%= radio_button("post", "category", "rails", options =
> {:onclick=>"javascript:redirect('QueryA1R1.rhtml')"}%>
>
> Amazingly I could not find one single example on the Internet or in  
> my Rails
> books, even the beta Agile Web Development with Rails.  I guess  
> that's one
> of the drawbacks of new technologies.  Most of the Rails books seem  
> very
> introductory and light on Rails, heavy on Ruby. The Agile books  
> seems to be
> the best so far.  I printed the entire pdf.
>
> Neil
> _______________________________________________
> Ruby at zenspider.com - Seattle.rb non-commercial list
> http://www.zenspider.com/seattle.rb
> http://www.zenspider.com/mailman/listinfo/ruby
>
>



More information about the Ruby mailing list