How to call a controller from the rake file, Just i have tried to create a controller object in rake, and call the method, but i didn''t get that... also how to link the helper class with the rake? -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/ewjMsae-ovoJ. 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.
On 25 January 2012 05:39, amvis <vgrkrishnan-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> How to call a controller from the rake file, Just i have tried to create a > controller object in rake, and call the method, but i didn''t get that... > also how to link the helper class with the rake?I don''t believe it makes sense to call controller methods from a rake task. Put the bits you want to call in a model and you can call them. Similarly to call view helper models does not make sense. There is no view so what good are view helpers? Put the code in models or in lib. 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.
can i use like this.. *myrake file* task :my_task => [:environment] do rd=*MofobirakesController*.new rd.index end *Controller file* * * * * class *MofobirakesController* < ApplicationController def index puts "hai rails3" end end what is the difference in that way to do in controller and in model..? -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/bP0dF4CYiOcJ. 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.
On 25 January 2012 08:36, amvis <vgrkrishnan-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> can i use like this.. > > myrake file > > task :my_task => [:environment] do > rd=MofobirakesController.new > rd.index > end > > Controller file > > > class MofobirakesController < ApplicationController > def index > puts "hai rails3" > end > end > > what is the difference in that way to do in controller and in model..?The difference is that controller actions are intended to be run in response to http requests. To try and run one as part of a rake action does not make logical sense. You ask at the top whether it would work, I have no idea whether it would work or not and it is irrelevant because there is no sense in doing it. If you have code that is common between a controller action and a rake task then the code should not be in a controller action. Move it to a model or into lib and call it from the controller and the rake task. What does the code that you want to call do? Colin> > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To view this discussion on the web visit > https://groups.google.com/d/msg/rubyonrails-talk/-/bP0dF4CYiOcJ. > > 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.-- gplus.to/clanlaw -- 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.
Basically i need to write one cron job for running the rake file from which, i''ll call one class, that have one query which will take data from some tables and will put into another tables. This is my objective. But now created one *.rb file in lib/ directory and created one .rake in task/ directory. *Also* call the .rb file from the rake.* This is now working.... Is it enough for my operation? Thank you vishnu -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/H9ZakQQ4L7QJ. 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.
On 25 January 2012 11:55, amvis <vgrkrishnan-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Basically i need to write one cron job for running the rake file from > which, i''ll call one class, that have one query which will take data from > some tables and will put into another tables. This is my objective. But now > created one .rb file in lib/ directory and created one .rake in task/ > directory. Also call the .rb file from the rake. This is now working.... > > Is it enough for my operation?I don''t understand, you say "This is now working" but then ask if it is enough. 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.