From: Jayce Meade Date: 2009-03-10T11:20:20+09:00 Subject: Re: Rails - MethodNotAllowed Error Sorry, my last was a bit garbled. Here's a better one: ActionController::Routing::Routes.draw do |map| # Home controller map.home '', :controller => "Home" map.root :home # Administration controller map.admin 'admin', :controller => "Administration" map.users 'admin', :controller => "Administration", :action => :users map.edit_user 'admin', :controller => "Administration", :action => :edit_user map.add_user 'admin', :controller => "Administration", :action => :add_user map.remove_user 'admin', :controller => "Administration", :action => :remove_user map.content_edit 'admin', :controller => "Administration", :action => :content_edit map.options 'admin', :controller => "Administration", :action => :options map.system_eval 'admin', :controller => "Administration", :action => :system_eval # Account controller map.logout 'logout', :controller => "Account", :action => "logout" map.login 'login', :controller => "Account", :action => "login" # About controller map.about 'about', :controller => "About" map.faq 'faq', :controller => "About", :action => "faq" map.getinvolved 'getinvolved', :controller => "About", :action => "getinvolved" map.showcase 'showcase', :controller => "About", :action => "showcase" # Blog controller map.blog 'blog', :controller => "Blog" # Forum controller map.forum 'forum', :controller => "Forum" # Contact controller map.contact 'contact', :controller => "Contact" end -------------------------------------------------- From: "Jayce Meade" Sent: Monday, March 09, 2009 7:12 PM To: "Ryan Davis" Subject: Re: Rails - MethodNotAllowed Error > Thanks. I've included my routes code below... I'm new to Rails, apologies > if it's terrible. I want to be able to create routes only for the actions > defined in the controllers... It looks impossible from what I've found > without manually assigning each and every one. > > tionController::Routing::Routes.draw do |map| > > # Home controller > map.home '', :controller => "Home" > map.root :home > > # Administration controller > map.admin 'admin', :controller => "Administration" > map.users 'admin', :controller => "Administration", :action => :users > map.edit_user 'admin', :controller => "Administration", :action => > :edit_user > map.add_user 'admin', :controller => "Administration", :action => > :add_user > map.remove_user 'admin', :controller => "Administration", :action => > :remove_user > map.content_edit 'admin', :controller => "Administration", :action => > :content_edit > map.options 'admin', :controller => "Administration", :action => :options > map.system_eval 'admin', :controller => "Administration", :action => > :system_eval > > # Account controller > map.logout 'logout', :controller => "Account", :action => "logout" > map.login 'login', :controller => "Account", :action => "login" > > # About controller > map.about 'about', :controller => "About" > map.faq 'faq', :controller => "About", :action => "faq" > map.getinvolved 'getinvolved', :controller => "About", :action => > "getinvolved" > map.showcase 'showcase', :controller => "About", :action => "showcase" > > # Blog controller > map.blog 'blog', :controller => "Blog" > > # Forum controller > map.forum 'forum', :controller => "Forum" > > # Contact controller > map.contact 'contact', :controller => "Contact" > end > > Looking back at this, I'm not entirely sure why I used 'admin' for each on > the administration controller, but I was also experimenting last night, > and I'm afraid I lose my train of thought easily. Like I said, I want to > be able to do something like > > http://www.mysite.com/admin/editcontent/ > > which will run the editcontent action in the administration controller > (defined by routes as admin, I want the full 'administration' as the > controller class, though, if that makes sense). > > http://www.mysite.com/admin/system_eval/0 > > to run the system_eval action in the administration controller with > params[:id] set to 0 so that I can identify the type of code being > evaluated. > > > Basically, I want as few possible entries in the routes.rb and as a > result -only- getting the actions in the controller mapped out as routes > for the program, nothing else, if that makes sense... > > > Am I being an idiot? > > - Jayce > > -------------------------------------------------- > From: "Ryan Davis" > Sent: Monday, March 09, 2009 6:14 PM > To: "Jayce Meade" > Subject: Re: Rails - MethodNotAllowed Error > >> >> On Mar 9, 2009, at 17:43 , Jayce Meade wrote: >> >>> I'm sorry, I'm having issues subscribing to the Rails mailing list, >>> so I'm hoping someone here will be able to help me. Below is an error I >>> continuously get whilst using Rails, however I do not know the cause... >>> The error description seems simple enough, but I have yet to identify >>> what is actually causing it. Can anyone help me? >> >> A better use of your time at this point is figuring out how to get on >> that list, rather than asking the question here. >> >>> ActionController::MethodNotAllowed >>> Only get, head, post, put, and delete requests are allowed.RAILS_ROOT: >>> /home/school/etc/rails_apps/main >>> >>> /usr/lib64/ruby/gems/1.8/gems/actionpack-2.1.1/lib/action_controller/ >>> routing/recognition_optimisation.rb:65:in `recognize_path' >>> /usr/lib64/ruby/gems/1.8/gems/actionpack-2.1.1/lib/action_controller/ >>> routing/route_set.rb:384:in `recognize' >> >> I can't tell w/o any code or relevant backtrace, but I'd guess that >> something in your routes.rb file is wrong. Binary elimination should >> find it quick enough. >> >>