John Merlino wrote in post #1019442: > Hey all, > > Rails guide doesnt cover with_options in Rails 3: > > http://guides.rubyonrails.org/routing.html > > The book The Rails 3 Way makes no reference to with_options except for > one page briefly. >
The docs say with_options is still part of rails 3.0.9: http://apidock.com/rails/Object/with_options ...but like a lot of rails stuff that method probably just serves to obfuscate your code--even though it's terser. > And I cannot find a decent tutorial to cover what I am trying to do. > > I have this: > > map.with_options Whoa. In rails 3, you write routes in a block that looks like this: TestApp::Application.routes.draw do ... end not like rails 2: ActionController::Routing::Routes.draw do |map| map.do_something end If you write this: TestApp::Application.routes.draw do map.foo.bar end ...then ruby doesn't know what map is. > :name_prefix => "dashboard_", :path_prefix => >"dashboard", :controller => "dashboard" do |dashboard| > dashboard.sidebar ".:format" > dashboard.charts ".:format" > dashboard.action_items ".:format" > dashboard.performance ".:format" > dashboard.site_menu ".:format" > dashboard.quick_links ".:format" > dashboard.perf_randomizations ".:format" > end > > Basically all of these methods "sidebar", "charts", etc are all methods > of the dashboard controller. I want them all to have a path helper of > dashboard_#{action}_url, where action is the action (e.g. > dashboard_sidebar_url). I want them all to be able to respond to both > html format and json. However, I dont know how to do this in Rails 3. > See if this works: match 'some/url' => "dashboard#sidebar", :as => "dashboard_sidebar" match 'another/url' => "dashboard#charts", :as => "dashboard_charts" -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.