Well say if i need app/models/abc.rb of an existing application ABC into new application DEF, then what all i need to do? There are so many files i need to be shared but did''nt have any fair idea how to get it. So rubians :), please help me on it. I think writing plugin is a fair idea. -- 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 in post #985888:> So rubians :), please help me on it. I think writing plugin is a fair > idea.Now, i thought of writing a plugin. So steps i done:- 1) Creates new rails app. 2) Creates plugin using ./script/generate plugin "NAME". This will create necessary files in vendor/plugins/"NAME" dir. 3) Changed vendor/plugins/"NAME"/init.rb to include the lib file. (/lib/"NAME".rb) 4) My lib/"NAME".rb looks like this. module "NAME" def hello return "hello" end def world return "world" end end 5) Creates a model and included the plugin into that model using require. require "NAME" I think this all is OK upto now. But after it when i go to console and type NAME.hello why does''nt it work.. It should work, right? Or i am missing something. Can anyone out there light me up :) -- 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.
Why don''t you just copy the model over to your new application? B. On Mon, Mar 7, 2011 at 1:25 AM, Hemant Bhargava <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org>wrote:> Hemant Bhargava wrote in post #985888: > > So rubians :), please help me on it. I think writing plugin is a fair > > idea. > > Now, i thought of writing a plugin. So steps i done:- > 1) Creates new rails app. > 2) Creates plugin using ./script/generate plugin "NAME". > This will create necessary files in vendor/plugins/"NAME" dir. > 3) Changed vendor/plugins/"NAME"/init.rb to include the lib file. > (/lib/"NAME".rb) > > 4) My lib/"NAME".rb looks like this. > module "NAME" > def hello > return "hello" > end > def world > return "world" > end > end > 5) Creates a model and included the plugin into that model using > require. > require "NAME" > I think this all is OK upto now. But after it when i go to console and > type NAME.hello why does''nt it work.. It should work, right? Or i am > missing something. > > Can anyone out there light me up :) > > -- > 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. > >-- 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.
On Mar 7, 7:25 am, Hemant Bhargava <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Hemant Bhargava wrote in post #985888: > 5) Creates a model and included the plugin into that model using > require. > require "NAME" > I think this all is OK upto now. But after it when i go to console and > type NAME.hello why does''nt it work.. It should work, right? Or i am > missing something. >Falling at the last hurdle - if you want to add a module''s method to a class you need to use include (require just loads the file containing the module - it doesn''t then do anything with that module). You can then do SomeClass.new.hello Fred -- 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.