vendredi 4 septembre 2015

Rails 3, Devise, Omniauth: No route matches {:action=>"update", :controller=>"users"}

I have 'Settings' page (users/edit), where logged in users can change their profile settings. The page is accessable for users logged in normally via sign in form using devise. When user logs in using omniauth google or facebook, going to this page the edit form gives routing error:

No route matches {:action=>"update", :controller=>"users", :format=>nil, :locale=>:en, :id=>#<User id: 1, email: "email@gmail.com", encrypted_password: "$2a$10$fbXnF6llZATbfcEa7w...", reset_password_token: "03824c95aebed5a785a407c5...", reset_password_sent_at: "2015-03-27 19:54:07", remember_created_at: nil, sign_in_count: 182, current_sign_in_at: "2015-09-04 08:22:28", last_sign_in_at: "2015-09-04 07:42:38", current_sign_in_ip: "127.0.0.1", last_sign_in_ip: "127.0.0.1", confirmation_token: nil, confirmed_at: "2013-12-25 06:09:41", confirmation_sent_at: "2013-12-25 06:07:05", unconfirmed_email: nil, created_at: "2013-12-25 06:07:05", updated_at: "2015-09-04 08:22:28", primary_phone: "55631806", secondary_phone: "", company_name: nil, company_reg: nil, company_kmkr: nil, address1: nil, address2: nil, city_id: nil, country_id: nil, state_id: nil, postal_code: nil, phone1: nil, phone2: nil, webpage: nil, information: nil, is_dealer: false, provider: "google_oauth2", uid: "109106508848551140861", oauth_token: nil, oauth_expires_at: nil, price_alert: true, sold_alert: true, interest_alert: true, auto_alerts: true, feature_alerts: false, locale: "en">}

Also when the user which has the same email in omniauth account tries to access this page via normal log in form gives the same error.

routes.rb:

require 'resque/server'
Webauto::Application.routes.draw do
devise_for :users, skip: [:session, :password, :registration, :confirmation], :controllers => { omniauth_callbacks: "omniauth_callbacks"}
scope '(:locale)' do
authenticated :user do
  root :to => 'cars#index'
end
root :to => "cars#index"
devise_for :users, :controllers => {:registrations => "registrations"}, skip: [:omniauth_callbacks]
resources :users,:except => [:show]
match "/users/dashboard" => "users#show", :as => :dashboard
as :user do
  get '/users/profile' => 'devise/registrations#edit', :as => :profile
  get '/users/settings' => 'users#edit',:as=>:settings
  match '/users/(:user_id)/contact' => 'users#contact',:as=>:contact_dealer,:via=>[:post]
end
end

users/edit.rb:

<% content_for :title,@title %>
<div class="row-fluid">
<div class="span3">
<%= render 'users/well',:active=>'settings' %>
</div>
<div class="span9">
<div class="page-header">
  <h2><%= t("users.settings.settings")  %></h2>
</div>
<%= vehicle_form_for @user, :html=>{:class=>"form-vertical"},:authenticity_token => true,:remote=>false do |f| %>
  <p class="lead">
    <%= t("users.settings.notifications")  %>
  </p>
  <p><%= t("users.settings.notify")  %></p>
  <%= f.check_box :price_alert,label: t("users.settings.price_alert") %>
  <%= f.check_box :sold_alert,label: t("users.settings.sold_alert") %>
  <%= f.check_box :interest_alert,label: t("users.settings.interest_alert") %>
    <br>
      <p class="lead">
        <%= t("users.settings.future_updates")  %>
      </p>
      <p><%= t("users.settings.future_updates_text")  %></p>
      <%= f.check_box :feature_alerts,label: t("users.settings.future_updates_check")  %>    
       <div style="padding-top:20px; margin-top:20px; border-top: 1px solid #eeeeee;">
      <%= f.submit t("users.profile.update"),:class=>"btn btn-info" %>
  </div>
      <% end %>
    </div>
  </div>

Aucun commentaire:

Enregistrer un commentaire