coolesting
2011-Sep-09 07:29 UTC
Changing the controller and action before that will be loaded.
Hi, guys. My problem is when i touch the route like ''/book/ruby'' that will loads the ApplicationController first, and then loads the action ruby of the controller book, the loading order as the following, # First loading class ApplicationController < ActionController::Base protect_from_forgery # # Here, can i change the controller book and the action ruby for loading later ? # For example , we change the controller book to video, or change the action ruby to php # If the controller be changed to video as i say above, so, the controller video will be loaded instead of the # the book. # end # loading later.. # A custom controller and sereral actions. class BookController < ActionController::Base def ruby #do something. end def php #do something. end def python #do something. end end Thanks in advance. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
coolesting
2011-Sep-09 07:33 UTC
Changing the controller and action before that will be loaded.
Hi, guys, my problem is when i touch the route like ''/myc/mya'' that will loads the application_controller first, and then loads the my_action of the my_controller, the loading order as the following, class ApplicationController < ActionController::Base protect_from_forgery end class MyController < ActionController::Base end -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Colin Law
2011-Sep-09 07:45 UTC
Re: Changing the controller and action before that will be loaded.
On 9 September 2011 08:29, coolesting <coolesting-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi, guys. > > My problem is when i touch the route like ''/book/ruby'' that will loads the > ApplicationController first, > and then loads the action ruby of the controller book, the loading order as > the following, > > # First loading > class ApplicationController < ActionController::Base > protect_from_forgery > # > # Here, can i change the controller book and the action ruby for loading > later ?Why not just change the route to invoke the action that you want? Colin -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
coolesting
2011-Sep-09 08:26 UTC
Re: Changing the controller and action before that will be loaded.
Because this situation is automatic, i don''t know it needs to change the controller book to which the anther controller or action. So, i can''t bundle it into route in that file, in other words, the controller or action name will be stored to database. On Sep 9, 12:45 am, Colin Law <clan...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> On 9 September 2011 08:29, coolesting <coolest...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > Hi, guys. > > > My problem is when i touch the route like ''/book/ruby'' that will loads the > > ApplicationController first, > > and then loads the action ruby of the controller book, the loading order as > > the following, > > > # First loading > > class ApplicationController < ActionController::Base > > protect_from_forgery > > # > > # Here, can i change the controller book and the action ruby for loading > > later ? > > Why not just change the route to invoke the action that you want? > > Colin-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
coolesting
2011-Sep-09 08:40 UTC
Re: Changing the controller and action before that will be loaded.
Because this controller or action name is automatic, it will be stored into database instead of that route file. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Michael Pavling
2011-Sep-09 08:50 UTC
Re: Changing the controller and action before that will be loaded.
On 9 September 2011 09:40, coolesting <coolesting-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Because this controller or action name is automatic, it will be stored > into database instead of that route file.(please leave some context from the message you''re replying to to save us the hassle of trawling through our deleted items :-/ If your user requests ''/books/ruby'' with standard routing it would pass the :id of ''ruby'' to the index action of the books controller (if you want your controller to be ''/book/'' you''ll need to map a custom route to that). So in the index action, if you perform some custom operation (like a case switch on params[:id] or a find_by_other_field) to determine which other method to call, you should be able to take it from there. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.