Hello All, I am using scaffolding but i can not figure out that how to write my own methods except CRUD. I mean i know how to use CRUD methods but if i write my own method in my controller and call that from views then the request is going to show method. Ok.. the scenario is that have an method abc_whatever in my controller. So i call this as ModelName/abc_whatever from the views. Before using scaffolding it was going fine but after scaffolding this request is going to show method. Is it something to do with routes..? Thanks in advance. -- 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-/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.
Yes, you have to create a route for that (see config/routes.rb) Tutorial: http://guides.rails.info/ Regards, Mirza On Jul 2, 8:59 am, Hemant Bhargava <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Hello All, > > I am using scaffolding but i can not figure out that how to write my own > methods except CRUD. I mean i know how to use CRUD methods but if i > write my own method in my controller and call that from views then the > request is going to show method. > > Ok.. the scenario is that have an method abc_whatever in my controller. > So i call this as ModelName/abc_whatever from the views. Before using > scaffolding it was going fine but after scaffolding this request is > going to show method. Is it something to do with routes..? > > Thanks in advance. > -- > Posted viahttp://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-/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.
IMHO, you really need to study the routes and how restful routing works. http://guides.rubyonrails.org/routing.html Scaffolding must have had generated the restful routing for the said controller and thus no other method except CRUD is being entertained unless specified. add your method in the file config/routes.rb like this... Say your controller is posts map.resources :posts, :collection => {:abc_whatever => :any} regards, Sur http://crimson9.com On Jul 2, 11:59 am, Hemant Bhargava <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Hello All, > > I am using scaffolding but i can not figure out that how to write my own > methods except CRUD. I mean i know how to use CRUD methods but if i > write my own method in my controller and call that from views then the > request is going to show method. > > Ok.. the scenario is that have an method abc_whatever in my controller. > So i call this as ModelName/abc_whatever from the views. Before using > scaffolding it was going fine but after scaffolding this request is > going to show method. Is it something to do with routes..? > > Thanks in advance. > -- > Posted viahttp://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-/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.
Sur Max wrote:> IMHO, you really need to study the routes and how restful routing > works. http://guides.rubyonrails.org/routing.html > Scaffolding must have had generated the restful routing for the said > controller and thus no other method except CRUD is being entertained > unless specified. > > add your method in the file config/routes.rb like this... > > Say your controller is posts > > map.resources :posts, :collection => {:abc_whatever => :any}Ok thanks a lot for your info. I''ll read them.> > > regards, > Sur > http://crimson9.com-- 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-/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.
Hemant Bhargava wrote:> Sur Max wrote: >> IMHO, you really need to study the routes and how restful routing >> works. http://guides.rubyonrails.org/routing.html >> Scaffolding must have had generated the restful routing for the said >> controller and thus no other method except CRUD is being entertained >> unless specified. >> >> add your method in the file config/routes.rb like this... >> >> Say your controller is posts >> >> map.resources :posts, :collection => {:abc_whatever => :any} > > Ok thanks a lot for your info. I''ll read them. > >> >> >> regards, >> Sur >> http://crimson9.comRyan Bates (http://railscasts.com/) might help you a lot when setting collection and member method from your class Controllers to your routes.rb file, it will show you some techniques efficiently like with_options and such ... (just check it out) Andre -- 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-/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.