plugin in rails · RubyonRails

Ferret in rails

View

<%= start_form_tag :action => ‘search_number’ %>

<div align=”center”>
<h3>Search Phonenumber By</h3>
<table>
<tr>

<td><select name=”searchfield” prompt=”select”>
<option selected>select</option>
<option value=”phonenumber” >Phonenumber</option>
<option value=”name” >Name</option>
<option value=”city” >City</option>
</select>
</td>
<td>
<%= text_field_tag ‘searchkey’ %>
<%= submit_tag “Search” %>

</tr>
</table>
</div>

<%= end_form_tag %>

Controller:

def search_number
if params[:searchfield]
session[:field]= params[:searchfield]
end
field = session[:field]

if params[:searchkey]
session[:query] = params[:searchkey]
end
query= session[:query]
@total, @phones = User.full_text_search(field,query, :page => (params[:page]||1))
@pages = pages_for(@total)
if @phones.length > 0
render :action=>’search_number’
else
render :text=>’No Result’
end

end

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s