[Instantrails-users] New User having some difficulties

Norm Scherer opencampground at earthlink.net
Mon Dec 8 11:02:16 EST 2008


Johnny Meek wrote:
> This is my first experience with InstantRails and RoR. I am running InstantRails on a Vista platform for educational / development use only. I am using a mySQL database. Note that I created the database and tables and populated the tables from a mysql command prompt - if that is relevant.
>
> In my database, I have a table named equipments. When I try to execute a query against it in a controller method - as basic as @var = Equipment.find(1) - I get an error message as follows: ActiveRecord::StatementInvalid - Table 'cars_development.equipment' doesn't exist.
>
> It appears that Rails is looking for a table named equipment rather than equipments. ?? The model for this table is very simple:
>
> class Equipment < ActiveRecord::Base
>     has_many :corvettes_equipments
> end
>
> Attempts I have made to correct the problem are: delete and re-create the models, drop and re-create the table, drop and re-create the database, created a new RoR project and copied the views, models and controller from the old project. None of this has worked for me.
>
> I finally tried creating a new table using a different name and this worked. As far as I know, I followed the same steps for this new table and model as I followed for the old one.
>
> This project is for a class, and I really need to use the table name that matches the assignment specs. The project will be graded using a database that my instructor builds and I can't exactly ask him to make a new table just to comply with my project's design.
>
> Thank you in advance for your response,
> Johnny Meek
>
>
>
>       
> _______________________________________________
> Instantrails-users mailing list
> Instantrails-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/instantrails-users
>
>   
Rails is opinionated.  It works best when you follow the conventions.  
If you want to use rails  it works best to go along with the program.  
There is an option in the model definition to use another name.

in model/equipment.rb
class Equipment < ActiveRecord::Base
  set_table_name "equipment"
  ...
end
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://rubyforge.org/pipermail/instantrails-users/attachments/20081208/3d978084/attachment.html>


More information about the Instantrails-users mailing list