ruby - Simple search form error in Rails -


i'm trying implement simple search form searches db keywords content being searched.

my view has form:

<%= form_tag search_keywords_path, :method => 'get' %>     <%= text_field_tag :search, params[:search] %>     <%= submit_tag "search", :name => nil %> <% end %> 

my controller has these:

def search     @keywords =  keyword.search(params[:search]) end  def show     @keyword = keyword.find(params[:id])     respond_to |format|     format.html # show.html.erb     format.json { render json: @keyword }     end end 

model keyword.rb:

def self.search(search)     if search     rails.logger.debug("debug::searching for" + search)     @keyword = keyword.find_all_by_content(search)     end end 

now, whenever try run search error :

activerecord::recordnotfound in keywordscontroller#show couldn't find keyword id=search

now understand, messing show method, don't why or how fix it. appreciated.

i think haven't added routes search action. can add routes search follows:

resources :keywords   collection     'search'   end end 

Comments

Popular posts from this blog

ios - iPhone/iPad different view orientations in different views , and apple approval process -

java Extracting Zip file -

C# WinForm - loading screen -