On August 17, 2010 03:16:06 am mikelb wrote:
> Hi all!
> 
> As a proof of concept, I created a table in sqlite database.  Very
> simple table "test" having fields "Id", "TestName", and "FTestVar".
> Non-standard, I know, but that is because I will be working with a
> crazy legacy database.
> 
> So......  I run a hobo generate statement:
> 
> ./script/generate hobo_model_resource test TestName:string
> FTestVar:boolean
> 

Test is not a good name for a model as it conflicts with a Rails class called 
test.

> and then go into the model and add:
> 
> set_table_name "test"
> 
> I fire up the server, and as soon as I try to hit the main page, I get
> this error:
> 

Did you run "script/generate hobo_migration" (which creates) the users table)?


> Read error: #<ActiveRecord::StatementInvalid: Could not find table
> 'tests'>
> /var/lib/gems/1.8/gems/activerecord-2.3.8/lib/active_record/
> connection_adapters/sqlite3_adapter.rb:29:in `table_structure'
> 
> Can anyone shed some light?  What should I do in working with legacy
> tables?
> 

I mimiced your example using a model called MyTest accessing a table called 
"test" and everything worked fine.

You should take a look at:

        http://cookbook.hobocentral.net/questions/34-how-do-i-build-a-hobo

which talks about building an application using existing tables.

Regards,
Henry

> BTW, I did my code generation using this script:
> http://pastie.org/1097156
> 
> by executing the following command:
> ./script/get_fields test Test | xargs  ruby script/generate
> hobo_model_resource Test
> 
> If that helps anything....
> 
> And here is the exact create statement for the sqlite table:
> CREATE TABLE "test" ("Id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
> "TestName" varchar(40), "FTestVar" bit);

-- 
Henry Baragar
Instantiated Software

-- 
You received this message because you are subscribed to the Google Groups "Hobo 
Users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/hobousers?hl=en.

Reply via email to