I have added the config.autoload_paths += %W(#{config.root}/lib) in my application.rb file.
Also I have added require "lib/api" to my routes.rb file
**What's missing?**
Daniel Doubrovkine
unread,
Jul 3, 2012, 8:44:25 AM7/3/12
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to ruby-...@googlegroups.com
In rails you shouldn't need to do the 'require' in routes.rb if the location of your api.rb is in the autoload_paths. If you place api.rb into lib, it should "just work" since lib is already autoloaded in Rails. What error(s) are you getting withotu any require or autoload_paths changes?
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to ruby-...@googlegroups.com
If I remove the require "lib/api" from routes.rb I get this error:
uninitialized constant MyApp
Thank you!
Daniel Doubrovkine
unread,
Jul 3, 2012, 10:02:55 AM7/3/12
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to ruby-...@googlegroups.com
Is lib/api a folder or lib/api.rb file? The file names and the class names should match in ruby, so if you have MyApp, it should be in my_app.rb and it should be on the load path.
Maria Serrano Cáceres
unread,
Jul 3, 2012, 10:29:51 AM7/3/12
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to ruby-...@googlegroups.com
Thank you. This was the problem. The module name should match in ruby with the file names. The problem was fixed for me :D.