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 %>
    <div class="form_row">
      <span style="float: right">
      <label for="q"></label>
      <%= text_field_tag "q", params[:q] %>
      <input type="submit" value="Search" />
      </span>
    </div>
<% end %>

In ma implementation..
Post belongs to user..
and Answer belongs to posts
-- 
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-t...@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