Rails 3 routing - what's best practice?
Posted
by Mattias
on Stack Overflow
See other posts from Stack Overflow
or by Mattias
Published on 2010-05-27T09:27:57Z
Indexed on
2010/05/27
9:31 UTC
Read the original article
Hit count: 273
ruby-on-rails
|ruby-on-rails3
Hi guys,
I'm trying out Rails, and I've stumbled across an issue with my routing.
I have a controller named "Account" (singular), which should handle various settings for the currently logged in user.
class AccountController < ApplicationController
def index
end
def settings
end
def email_settings
end
end
How would I set-up the routes for this in a proper manner? At the moment I have:
match 'account(/:action)', :to => 'account', :as => 'account'
This however does not automagically produce methods like account_settings_path
but only account_path
Is there any better practice of doing this? Remember the Account
controller doesn't represent a controller for an ActiveModel.
If this is in fact the best practice, how would I generate links in my views for the actions? url_to :controller => :account, :action => :email_settings
?
Thanks!
© Stack Overflow or respective owner