Hello, I am a beginner in rails and i want to create a class and access it from the controller in rails 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.
Make a file "class_name.rb" and define your class(put it in the lib directory) Then in the controller use <require ''class_name''> Instantiate it inside your controller and off you go =D 2012/2/7 M.SH <shehata.mohammed-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>> Hello, > I am a beginner in rails and i want to create a class and access it > from the controller in rails > > 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. > >-- 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.
if you want your class wired to a database table then you would create the class in model directory. The easiest way to do this is to run the scaffold command which you can find in the rails documentation. On Feb 7, 11:57 am, Benjamin Iandavid Rodriguez <ian....-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Make a file "class_name.rb" and define your class(put it in the lib > directory) > > Then in the controller use <require ''class_name''> > > Instantiate it inside your controller and off you go =D > > 2012/2/7 M.SH <shehata.moham...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > > > > > > > > > Hello, > > I am a beginner in rails and i want to create a class and access it > > from the controller in rails > > > 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.-- 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.
Thank you for you replies @Benjamin i made what you say but doesn''t work with me but i found that to put require ''file_name.rb'' in config/environment.rb and works well Thanks for all M.SH On Feb 7, 10:14 pm, gerbdla <gerb...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> if you want your class wired to a database table then you would create > the class in model directory. The easiest > way to do this is to run the scaffold command which you can find in > the rails > documentation. > > On Feb 7, 11:57 am, Benjamin Iandavid Rodriguez <ian....-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > wrote: > > > > > > > > > Make a file "class_name.rb" and define your class(put it in the lib > > directory) > > > Then in the controller use <require ''class_name''> > > > Instantiate it inside your controller and off you go =D > > > 2012/2/7 M.SH <shehata.moham...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > > > > Hello, > > > I am a beginner in rails and i want to create a class and access it > > > from the controller in rails > > > > 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-/JYPxA39Uh4Ykp1iOSErHA@public.gmane.orgm. > > > 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.-- 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.