Searching by tag

Hello sir,
i hav implemented a web application in which a user posts a question and
the answer will be provided by an EXPERT who has logged in…
The question posted wil hav tag,title and ques_string…
now i want to implement a search method so that the user can search a
question based on the tag and the answer will also be retrieved…
for this i hav used ‘acts_as_ferret’ plugin…
ma question is can u help me in implementing the search method so that
on clickin the query along with the answer will be retrieved bases on
the tag given by user…

code implemented by me for search is:

def search
if params[:q]
query = params[:q]
# First find the user hits…
@psts = Post.find_by_contents(query, :limit => :all)
# …then the subhits.

@psts.each { |post| post ||= Post.new }
@psts = @psts.sort_by { |post| post.tag }
@invalid = true

end
end

partial form for search…

<% form_tag({ :action => “search” }, :method => “get”) do %>




<%= text_field_tag “q”, params[:q] %>



<% end %>

In ma implementation…
Post belongs to user…
and Answer belongs to posts

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs