mercredi 15 avril 2015

no route matches when I submit a form search


Vote count:

0




I'm having troubles with a route in Rails. I'm trying to build a search form. I have an html form in the root_path (static_pages#index) view. I want when submit this form with the keywords that the results of spots which contain those tags are displayed in another view controlled by searchesController (searches#index). When I submit the console tells me 'no route matches get '/search' ' and I don't know why


This is the code of my routes


config/routes.rb



Rails.application.routes.draw do
get 'maps/:name' => 'maps#spot', :as => :spot_map


devise_for :users, :controllers => { :omniauth_callbacks => "users/omniauth_callbacks" }

devise_scope :user do
get 'sign_out', :to => 'devise/sessions#destroy', :as => :destroy_session
end

resources :users do
resources :spots do
resources :offers
end
end

root 'static_pages#index'
get 'search/:query' => 'searches#index', :as => "query"
get 'search/spot/:id' => 'searches#show', :as => :search_result
get 'tags/:tag' => 'static_pages#index', :as => "tag"
get 'register' => 'static_pages#register', :as => :register
get 'users/:id/profile' => 'profiles#show', :as => :user_profile

get 'maps/homepage' => 'maps#homepage', :as => :homepage_map


mount Attachinary::Engine => "/attachinary"
end


This is the code of the view (static_pages#index) where I have the html form. /static_pages/views/index.html.erb I've tried with action="/search" as well



<form action="query" method='get'>
<div class="row collapse postfix-round">
<div class="small-10 columns">
<input id="home-placeholder" class="" type="search" name="query" placeholder="">
</div>
<div class="small-2 columns">
<input type="submit" class="button postfix" value="Buscar"/>
</div>
</div>
</form>


This is the code of my controller


controllers/searches_controller.rb



class SearchesController

def index
@user = current_user if current_user
@spots = Spot.full_text_search(params[:query])
end

end


asked 32 secs ago







no route matches when I submit a form search

Aucun commentaire:

Enregistrer un commentaire