Ruby on Rails Thursday, April 25, 2013

On Apr 25, 2013, at 11:20 AM, Brentwood R. wrote:

> I may be going about this the wrong way. Any advice would be great.

You are possibly confused on more than 1 issue, but there's not enough info in your message to be sure or to let anyone provide a really complete answer. (In particular, do you expect the user to enter the value and then be able to perform the search all in the page, or is the user submitting a form back to the server and a new page being rendered?)

That said:

1) The ruby code in the rails controller runs just before render, and affects the page that is sent to the browser. So the controller might change the javascript that's in the page as it's sent, but no ruby code will be run and no ruby variables will be evaluated after it's sent.

2) highlight('@found'); will pass the literal string @found to the highlight function, if you want to substitute a ruby variable value in there, you need highlight('<%= @found %>')--assuming of course that @found has its value while the page is being rendered

3) What do you mean by "does not assign the variable"? What ruby will get in the post is a hash of params, and it's up to you how you use that. In the most common use, you'd use a form with a model object, but here you're just trying to get 1 value, so use of form_tag is probably appropriate, and in that case you want text_field_tag, not text_field.


--
Scott Ribe
scott_ribe@elevated-dev.com
http://www.elevated-dev.com/
(303) 722-0567 voice




--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

No comments:

Post a Comment