3

In my rails app i go for example to devise sign up action (http://*:3000/users/sign_up) and get error:

No route matches {:controller=>"devise/vehicle_types", :action=>"search_vehicle_type"}

I thing it's becouse i'm in devise namespace of routing... But how can i normally render sign up view? My layout part look's so:

= render :partial => 'vehicle_types/findtype'   

and this partial:

.form
  = form_tag :controller => 'vehicle_types', :action => 'search_vehicle_type' do 
    = select("post", "MFA_ID", Manufacturer.all.collect {|p| [ p.MFA_BRAND, p.MFA_ID ] }, {:prompt => 'Марка'}, :class => "login-input man-select")
    = select_tag "models", options_for_select(['Модель', nil]), :class => "login-input mod-select", :prompt => 'Модель', :disabled => :true
    = select_tag "fueltype", options_for_select([['Тип топлива', nil], ['Не важно', nil], ['Бензин', 53302], ['Дизель', 53205], ['Газ', 53241], ['Гибрид', 55554], ['Электродвигатель', 52433]]), :class => "login-input fuel-select"
    = text_field_tag "year", nil, :placeholder => "Год выпуска", :class => "login-input"
    .submit-area
      .left
        = submit_tag "Выбор", :class => "orange-button"

On other pages (non-devise) all is ok, but when i go to password recovery, or sign up i get erros. But why? And how to solve it?

Also part of routes:

Oleg::Application.routes.draw do 
devise_for :users
match '/search_vehicle_type' => 'vehicle_types#search_vehicle_type'
root :to => 'pages#index'
end

Also i read about links here https://github.com/plataformatec/devise/issues/471, but how for partial to do?

and rake routes | grep devise

new_admin_session GET    /admins/sign_in(.:format)                                                 devise/sessions#new
                  admin_session POST   /admins/sign_in(.:format)                                                 devise/sessions#create
          destroy_admin_session DELETE /admins/sign_out(.:format)                                                devise/sessions#destroy
                 admin_password POST   /admins/password(.:format)                                                devise/passwords#create
             new_admin_password GET    /admins/password/new(.:format)                                            devise/passwords#new
            edit_admin_password GET    /admins/password/edit(.:format)                                           devise/passwords#edit
                                PUT    /admins/password(.:format)                                                devise/passwords#update
      cancel_admin_registration GET    /admins/cancel(.:format)                                                  devise/registrations#cancel
             admin_registration POST   /admins(.:format)                                                         devise/registrations#create
         new_admin_registration GET    /admins/sign_up(.:format)                                                 devise/registrations#new
        edit_admin_registration GET    /admins/edit(.:format)                                                    devise/registrations#edit
                                PUT    /admins(.:format)                                                         devise/registrations#update
                                DELETE /admins(.:format)                                                         devise/registrations#destroy
               new_user_session GET    /users/sign_in(.:format)                                                  devise/sessions#new
                   user_session POST   /users/sign_in(.:format)                                                  devise/sessions#create
           destroy_user_session DELETE /users/sign_out(.:format)                                                 devise/sessions#destroy
                  user_password POST   /users/password(.:format)                                                 devise/passwords#create
              new_user_password GET    /users/password/new(.:format)                                             devise/passwords#new
             edit_user_password GET    /users/password/edit(.:format)                                            devise/passwords#edit
                                PUT    /users/password(.:format)                                                 devise/passwords#update
       cancel_user_registration GET    /users/cancel(.:format)                                                   devise/registrations#cancel
              user_registration POST   /users(.:format)                                                          devise/registrations#create
          new_user_registration GET    /users/sign_up(.:format)                                                  devise/registrations#new
         edit_user_registration GET    /users/edit(.:format)                                                     devise/registrations#edit
                                PUT    /users(.:format)                                                          devise/registrations#update
                                DELETE /users(.:format)                                                          devise/registrations#destroy
brabertaser19
  • 5,678
  • 16
  • 78
  • 184

1 Answers1

0

While it may not be the best style, the easiest fix to this is to use an actual path in the form_tag:

.form
  = form_tag "/search_vehicle_type" do
  # Rest of the form

Another alternative would be to name the route in your routes.rb file:

match '/search_vehicle_type' => 'vehicle_types#search_vehicle_type', :as => :search_vehicle_type

Then use that named route in the form_tag:

.form
  = form_tag search_vehicle_type_path do
  # Rest of the form
Troy
  • 5,319
  • 1
  • 35
  • 41
  • search_vehicle_type is a partial, i didn't have in layout any forms, only in partial search_vehicle_type, i write in layout: = render :partial => "blablabla/search_vehicle_type", so must i write it in this partial? Did you mean that? – brabertaser19 Dec 26 '12 at 08:43
  • also, to do not new question, give me please advise: i have built-in devise controller (haven't generated own) is it any way to realize recaptcha gem validation? (or will i need to create controller and set validate_recaptcha?) – brabertaser19 Dec 26 '12 at 21:25
  • I was not referring you the name of your partial. The issue here is that your form is posting to a route that doesn't exist, so I suggested that you specify the actual route either by typing the path (first code block) or naming it and using the name (second and third code block). The name used in the second code block happens to match the name of your partial, but could be anything. The key is that the "as" part of the match line is used in the form_tag's path parameter. – Troy Dec 26 '12 at 21:45
  • all is ok now... also if you give a name, than is good to write = form_tag :search_vehicle_type – brabertaser19 Dec 26 '12 at 21:49