dalababa16-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2008-Nov-11 18:35 UTC
Where to put custmized files in Rails app?
All, This is the first time to play on Rails application. Simple questions: where to locate/store my own *.rb, and *.txt files in my Rails app? I put my *.rb in the components folder so that controllers can see them without problems. Is this the right place to do that? But I may not know where to put *.txt files and how to locate them in controllers. Thank you 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
the "components" dir is deprecated and removed in v2.0+ AFAIK you''d be better off using the lib dir or making a plugin. On Nov 11, 1:35 pm, "dalabab...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org" <dalabab...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> All, > > This is the first time to play on Rails application. Simple questions: > where to locate/store my own *.rb, and *.txt files in my Rails app? > I put my *.rb in the components folder so that controllers can see > them without problems. Is this the right place to do that? > But I may not know where to put *.txt files and how to locate them in > controllers. > > Thank you 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-/JYPxA39Uh5TLH3MbocFFw@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 -~----------~----~----~----~------~----~------~--~---
dalababa16-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2008-Nov-12 04:52 UTC
Re: Where to put custmized files in Rails app?
Thank you for the response. I am practicing on v1.7 and it works fine. But, if I move the code from components to comp dir in lib, the controller can not fine those fine any more. If I put those files in lib directly, it woks fine again. How can I maintain a structure of directories in Rails? Thanks, - On Nov 11, 4:15 pm, jemminger <jemmin...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> the "components" dir is deprecated and removed in v2.0+ AFAIK > > you''d be better off using the lib dir or making a plugin. > > On Nov 11, 1:35 pm, "dalabab...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org" <dalabab...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > wrote: > > > > > All, > > > This is the first time to play on Rails application. Simple questions: > > where to locate/store my own *.rb, and *.txt files in my Rails app? > > I put my *.rb in the components folder so that controllers can see > > them without problems. Is this the right place to do that? > > But I may not know where to put *.txt files and how to locate them in > > controllers. > > > Thank you in advance. > > -- Hide quoted text - > > - Show quoted text ---~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@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 -~----------~----~----~----~------~----~------~--~---
Why do you need to maintain a directory of files? There are preset directories already for anything you do with the Rails MVC framework and the lib directory gives you a spot to put additional modules. Static files that get pushed to the users belong in the public/ directory, etc. You will need to require the files manually if you use your own subdirectories. --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
The lib directory is included by rails automatically, so any file in there will be included. If you put it elsewhere you''ll have to specifically require them yourself. On Nov 11, 11:52 pm, "dalabab...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org" <dalabab...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Thank you for the response. > > I am practicing on v1.7 and it works fine. But, if I move the code > from components to comp dir in lib, the controller can not fine those > fine any more. If I put those files in lib directly, it woks fine > again. How can I maintain a structure of directories in Rails? > > Thanks, > > - > > On Nov 11, 4:15 pm, jemminger <jemmin...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > the "components" dir is deprecated and removed in v2.0+ AFAIK > > > you''d be better off using the lib dir or making a plugin. > > > On Nov 11, 1:35 pm, "dalabab...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org" <dalabab...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > > wrote: > > > > All, > > > > This is the first time to play on Rails application. Simple questions: > > > where to locate/store my own *.rb, and *.txt files in my Rails app? > > > I put my *.rb in the components folder so that controllers can see > > > them without problems. Is this the right place to do that? > > > But I may not know where to put *.txt files and how to locate them in > > > controllers. > > > > Thank you in advance. > > > -- Hide quoted text - > > > - Show quoted text ---~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@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 -~----------~----~----~----~------~----~------~--~---
dalababa16-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2008-Nov-12 18:41 UTC
Re: Where to put custmized files in Rails app?
I may not want to have a directory of files anywhere that much but, what if I want to separate my *rb files from *xml files? The case I am having now is that I have to put all my own files in a signal lib directory which I may not like it very much. Is this ture that I cannot have a sub directory in lib? On Nov 12, 8:13 am, jemminger <jemmin...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> The lib directory is included by rails automatically, so any file in > there will be included. If you put it elsewhere you''ll have to > specifically require them yourself. > > On Nov 11, 11:52 pm, "dalabab...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org" <dalabab...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > wrote: > > > > > Thank you for the response. > > > I am practicing on v1.7 and it works fine. But, if I move the code > > from components to comp dir in lib, the controller can not fine those > > fine any more. If I put those files in lib directly, it woks fine > > again. How can I maintain a structure of directories in Rails? > > > Thanks, > > > - > > > On Nov 11, 4:15 pm, jemminger <jemmin...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > the "components" dir is deprecated and removed in v2.0+ AFAIK > > > > you''d be better off using the lib dir or making a plugin. > > > > On Nov 11, 1:35 pm, "dalabab...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org" <dalabab...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > > > wrote: > > > > > All, > > > > > This is the first time to play on Rails application. Simple questions: > > > > where to locate/store my own *.rb, and *.txt files in my Rails app? > > > > I put my *.rb in the components folder so that controllers can see > > > > them without problems. Is this the right place to do that? > > > > But I may not know where to put *.txt files and how to locate them in > > > > controllers. > > > > > Thank you in advance. > > > > -- Hide quoted text - > > > > - Show quoted text -- Hide quoted text - > > - Show quoted text ---~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@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 -~----------~----~----~----~------~----~------~--~---
you can have as many subdirectories in lib or anywhere else you want. you will just have to explicitly require those files or write something to auto-require the files in those dirs. e.g. if you make "lib/myfiles/foo.rb", you''ll have to put "require ''myfiles/foo.rb''" to use it On Nov 12, 1:41 pm, "dalabab...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org" <dalabab...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I may not want to have a directory of files anywhere that much but, > what if I want to separate my *rb files from *xml files? The case I am > having now is that I have to put all my own files in a signal lib > directory which I may not like it very much. Is this ture that I > cannot have a sub directory in lib? > > On Nov 12, 8:13 am, jemminger <jemmin...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > > The lib directory is included by rails automatically, so any file in > > there will be included. If you put it elsewhere you''ll have to > > specifically require them yourself. > > > On Nov 11, 11:52 pm, "dalabab...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org" <dalabab...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > > wrote: > > > > Thank you for the response. > > > > I am practicing on v1.7 and it works fine. But, if I move the code > > > from components to comp dir in lib, the controller can not fine those > > > fine any more. If I put those files in lib directly, it woks fine > > > again. How can I maintain a structure of directories in Rails? > > > > Thanks, > > > > - > > > > On Nov 11, 4:15 pm, jemminger <jemmin...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > the "components" dir is deprecated and removed in v2.0+ AFAIK > > > > > you''d be better off using the lib dir or making a plugin. > > > > > On Nov 11, 1:35 pm, "dalabab...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org" <dalabab...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > > > > wrote: > > > > > > All, > > > > > > This is the first time to play on Rails application. Simple questions: > > > > > where to locate/store my own *.rb, and *.txt files in my Rails app? > > > > > I put my *.rb in the components folder so that controllers can see > > > > > them without problems. Is this the right place to do that? > > > > > But I may not know where to put *.txt files and how to locate them in > > > > > controllers. > > > > > > Thank you in advance. > > > > > -- Hide quoted text - > > > > > - Show quoted text -- Hide quoted text - > > > - Show quoted text ---~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@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 -~----------~----~----~----~------~----~------~--~---
dalababa-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2008-Nov-12 20:52 UTC
Re: Where to put custmized files in Rails app?
Thank you, jemminger. That works for me now. However, I''ve got another issue. I have an my_parse.rb file to parse an xml file. The directory for these files is lib/myfiles/my_parse.rb, and lib/myfiles/xml/aa.xml. And also I have a test file in test/unit/my_parse_test.rb. The error message is: Errno::ENOENT: No such file or directory - xml/aa.xml when I put the path to the aa.xml flie like this - xml/aa.xml in my_parse_test.rb. But, it is OK if the aa.xml is in the same dir as my_parse.rb is with the path - aa.xml. So, what is the right path to the aa.xml in my_parse.rb if I put aa.xml file in xml/aa.xml? (like this: lib/myfiles/my_parse.rb, and lib/myfiles/xml/aa.xml) On Nov 12, 2:55 pm, jemminger <jemmin...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> you can have as many subdirectories in lib or anywhere else you want. > you will just have to explicitly require those files or write > something to auto-require the files in those dirs. > > e.g. if you make "lib/myfiles/foo.rb", you''ll have to put "require > ''myfiles/foo.rb''" to use it > > On Nov 12, 1:41 pm, "dalabab...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org" <dalabab...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > wrote: > > > > > I may not want to have a directory of files anywhere that much but, > > what if I want to separate my *rb files from *xml files? The case I am > > having now is that I have to put all my own files in a signal lib > > directory which I may not like it very much. Is this ture that I > > cannot have a sub directory in lib? > > > On Nov 12, 8:13 am, jemminger <jemmin...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > The lib directory is included by rails automatically, so any file in > > > there will be included. If you put it elsewhere you''ll have to > > > specifically require them yourself. > > > > On Nov 11, 11:52 pm, "dalabab...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org" <dalabab...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > > > wrote: > > > > > Thank you for the response. > > > > > I am practicing on v1.7 and it works fine. But, if I move the code > > > > from components to comp dir in lib, the controller can not fine those > > > > fine any more. If I put those files in lib directly, it woks fine > > > > again. How can I maintain a structure of directories in Rails? > > > > > Thanks, > > > > > - > > > > > On Nov 11, 4:15 pm, jemminger <jemmin...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > the "components" dir is deprecated and removed in v2.0+ AFAIK > > > > > > you''d be better off using the lib dir or making a plugin. > > > > > > On Nov 11, 1:35 pm, "dalabab...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org" <dalabab...-Re5JQEeQqe8@public.gmane.orgm> > > > > > wrote: > > > > > > > All, > > > > > > > This is the first time to play on Rails application. Simple questions: > > > > > > where to locate/store my own *.rb, and *.txt files in my Rails app? > > > > > > I put my *.rb in the components folder so that controllers can see > > > > > > them without problems. Is this the right place to do that? > > > > > > But I may not know where to put *.txt files and how to locate them in > > > > > > controllers. > > > > > > > Thank you in advance. > > > > > > -- Hide quoted text - > > > > > > - Show quoted text -- Hide quoted text - > > > > - Show quoted text -- Hide quoted text - > > - Show quoted text ---~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@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 -~----------~----~----~----~------~----~------~--~---
dalababa-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2008-Nov-13 02:34 UTC
Re: Where to put custmized files in Rails app?
All right, I got it. I should use __FILE__ to identify the path of my_parser.rb and then to locate the xml file. On Nov 12, 3:52 pm, "dalab...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org" <dalabab...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Thank you, jemminger. > > That works for me now. However, I''ve got another issue. I have an > my_parse.rb file to parse an xml file. The directory for these files > is lib/myfiles/my_parse.rb, and lib/myfiles/xml/aa.xml. And also I > have a test file in test/unit/my_parse_test.rb. The error message is: > Errno::ENOENT: No such file or directory - xml/aa.xml when I put the > path to the aa.xml flie like this - xml/aa.xml in my_parse_test.rb. > But, it is OK if the aa.xml is in the same dir as my_parse.rb is with > the path - aa.xml. > So, what is the right path to the aa.xml in my_parse.rb if I put > aa.xml file in xml/aa.xml? > (like this: lib/myfiles/my_parse.rb, and lib/myfiles/xml/aa.xml) > > On Nov 12, 2:55 pm, jemminger <jemmin...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > you can have as many subdirectories in lib or anywhere else you want. > > you will just have to explicitly require those files or write > > something to auto-require the files in those dirs. > > > e.g. if you make "lib/myfiles/foo.rb", you''ll have to put "require > > ''myfiles/foo.rb''" to use it > > > On Nov 12, 1:41 pm, "dalabab...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org" <dalabab...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > > wrote: > > > > I may not want to have a directory of files anywhere that much but, > > > what if I want to separate my *rb files from *xml files? The case I am > > > having now is that I have to put all my own files in a signal lib > > > directory which I may not like it very much. Is this ture that I > > > cannot have a sub directory in lib? > > > > On Nov 12, 8:13 am, jemminger <jemmin...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > The lib directory is included by rails automatically, so any file in > > > > there will be included. If you put it elsewhere you''ll have to > > > > specifically require them yourself. > > > > > On Nov 11, 11:52 pm, "dalabab...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org" <dalabab...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > > > > wrote: > > > > > > Thank you for the response. > > > > > > I am practicing on v1.7 and it works fine. But, if I move the code > > > > > from components to comp dir in lib, the controller can not fine those > > > > > fine any more. If I put those files in lib directly, it woks fine > > > > > again. How can I maintain a structure of directories in Rails? > > > > > > Thanks, > > > > > > - > > > > > > On Nov 11, 4:15 pm, jemminger <jemmin...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > > the "components" dir is deprecated and removed in v2.0+ AFAIK > > > > > > > you''d be better off using the lib dir or making a plugin. > > > > > > > On Nov 11, 1:35 pm, "dalabab...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org" <dalabab...@gmail.com> > > > > > > wrote: > > > > > > > > All, > > > > > > > > This is the first time to play on Rails application. Simple questions: > > > > > > > where to locate/store my own *.rb, and *.txt files in my Rails app? > > > > > > > I put my *.rb in the components folder so that controllers can see > > > > > > > them without problems. Is this the right place to do that? > > > > > > > But I may not know where to put *.txt files and how to locate them in > > > > > > > controllers. > > > > > > > > Thank you in advance. > > > > > > > -- Hide quoted text - > > > > > > > - Show quoted text -- Hide quoted text - > > > > > - Show quoted text -- Hide quoted text - > > > - Show quoted text -- Hide quoted text - > > - Show quoted text ---~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@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 -~----------~----~----~----~------~----~------~--~---