aash dhariya wrote in post #1057118:
> Maybe this could be your answer:
>
> def self.search(params)
>    if params
>       query = "SELECT * FROM Hotel where city LIKE '#{params[:search]}'
> OR
> name LIKE '#{params[:search]}'"
>       query+= "AND rating = #{params[:rating]}" if params[:rating]
>       @hotels = find_by_sql(query)
>      arel
>    else
>      @hotels = Hotel.all
>    end
>  end
Unforunatly the code above does not work. Its a logical error.


And:


>   <% @hotels.each do |hotel| %>
>      <p>hotel.name</p>

Isn't showing any hotels at all, even with the search empty.
All I altered from your code was
>query = "SELECT * FROM Hotel
to
query = "SELECT * FROM hotels

which is the name of the table.

If anyone has anymore tips, I would really appreciate it.

Best Regards

-- 
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+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to