I have a has_one association between user and setting model. I have also SettingsController with edit and update actions. On front page I have a link to edit settings:
<%= link_to (settings_path(current_user.setting)), do %>
..
<% end %>
This causing ActionController::RoutingError No route matches {:controller=>”settings”, :action=>”edit”} ..when trying to display front page.
I kinda stuck banging my head around why this is happening. Using Devise for user authentication, this current_user should be a global variable.
Here is how routes are defined in routes.rb:
resources :setting, :only => [:edit, :update]
match '/settings/:id' => "settings#edit", :controller => :setting, :as => :settings
Here is what rake routes is returning:
edit_setting GET /setting/:id/edit(.:format) {:action=>"edit", :controller=>"setting"}
setting PUT /setting/:id(.:format) {:action=>"update", :controller=>"setting"}
settings /settings/:id(.:format) {:controller=>"settings", :action=>"edit"}
Another guess is that controller name (SettingsController) should be singular, not plural when using has_one association. For some strange reason Rails is not noticing my controller, even though it is very present.
Help is appreciated.
Ok, firts why are you using your own controller for settings for a user instead of devise ?
that is on
edit_user_registration_path:asparameterAnother comment is , if you are using
resources :setting, :only => [:edit, :update]why are you using the next line ? and that path, I mean, if you declaring it like that, you could use
edit_setting_path(id)