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.