Topic: Please help!!!

Hi, I am new to rails and would need some help on the following things

1) I have a database persons.. I need to search the table people in the following manner

If the user enter
first Name : John
Middle Name :
Last Name : anderson


i need to search the database as
%John% and %Anderson%

I have wriiten the foolowng code but the params[:person] does not get the "%" after the execution.


params[:person].delete_if{|key,value|value==""}
params[:person].each_value{|value| value='%'+value+'%'}
@people = Person.find_all(params[:person])


please tell me what do i need to do.. The thing is the user may enter some fields for person and may not enter the other fields and hence are left blank. but i need to find out which fields are entered and make a search accordingly including the wildcard i.e % on boht the ends of the word that the user has entered.


2) My second question is that if i need to submit a form using a link what do i do.

for e.g
in Edit
to update the name of a field i have an update link and when the user clicks oin tha t link
the name should get updated.
relatiosn is the name of the table

<%@realtions.each do |relation|%>
<td width = "60%"><align="center"><%=text_field_tag("relation_name", relation.relation_name ,options={:size=>"91"})%></td>
</div>
<td width = "10%"><p align="center"><b><%=link_to( "Update",
                                                  {:action => "update_relation_name",:id=>relation.id},:method=>:put)%>


IN MY Controller i have


def update_relation_name
  if request.post?
  @relation = Relation.find(params[:id])
  @relation.relation_name = params[:rel_name]
   relation.update_attributes(params[:relation])
    flash[:notice] = 'Relation Name Successfully updated'
    redirect_to :action=>'relman'
    end
end


The problem i have is my realtion does not get updates.

Please help

Thank you.

Re: Please help!!!

sorry i have typed wring controller in the above post the controller is as

def update_relation_name
  @relation = Relation.find(params[:id])
  @relation.relation_name = params[:rel_name]
   relation.update_attributes(params[:relation])
    flash[:notice] = 'Relation Name Successfully updated'
    redirect_to :action=>'relman'
end

Re: Please help!!!

#1: You could use acts_as_ferret for this.

#2: Why would you use a link to do this? You could set a style on the submit button so it doesn't look like a submit button.