I’m using Ruby on Rails 2.3.8 and I’d like to know how to organize models in subfolders so Ruby can recognize them.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
To the best of my understanding, you need to namespace your models in order for them to be loaded.
to use the generator:
will create the model in
app/models/customer/address.rbIt will load recursively, but in order for rails to find it, it will need to have the namespace that lines up with the path.
Fair warning that when you use the generator (at least in rails 2.3.5 and lower is all I have tested this in). It will create table name as
customer_addresses, but the model will by default still look for a table name ofaddresses. You will either need to change the migration database name to addresses or addset_table_name 'customers_addresses'or similar to get the two to line up.