Here's some skeletal code to get you started based on what I think is necessary from what you said. Hope this is helpful.
For the search bit, you can do something like this in your index view:
<%= form_for User.new, :url => "search" do |f| %>
<%= f.label :name %>
<%- f.text_field :name %>
<%- end %>
In your controller:
def search
q = params[:user][:name]
@users = User.find(:all, :conditions => ["name LIKE %?%",q])
end
and in your search mode:
<%-@users.each do |user| %>
Name: <%=user.name %>
<%- user.achievements.each do |achievement| %>
<%= achievement.name %>
<%- end %>
<%- end %>
Of course, you need to make sure that users and achievement models are correctly connected:
class User << ActiveRecord::Base
has_many :achievements
end
source
share