Can you help me with search in Ruby on Rails?
I'm trying to create a way to search in my Ruby on Rails program. I am using the TextSearch plugin which seems to be working ok. The problem I am having is passing the info from the view to the controller.
My controller, again based on TextSearch, is simply: Code:
def search Code:
<table> |
In your controller, you call query, but query isn't defined anywhere. What you probably want is params['query'].
So, in your controller, first do Code:
@query = params['query'] Code:
@results = Product.search @query # Note the @query instead of query, because I assigned params['query'] to @query instead of to query Code:
<td width="50" <%= text_field_tag 'query', @query %> Lastly, there don't seem to be many Rails coders on this forum (I've only just registered myself and I'm not a habitual reader), so next time asking your question on the excellent "Ruby on Rails: Talk" Google group may give you an answer sooner. |
All times are GMT -5. The time now is 06:35 PM. |