# Routes, sqlite3

**URL:** <https://www.ruby-forum.com/t/routes-sqlite3/172985>\
**Category:** Rails\
**Created:** [July 30, 2009, 8:37pm UTC](https://www.ruby-forum.com/t/routes-sqlite3/172985 "2009-07-30T20:37:53Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![rubystudent](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/e9c0ed/32.png) [@rubystudent](https://www.ruby-forum.com/u/rubystudent)\
**Post date:** [July 30, 2009, 8:37pm UTC](https://www.ruby-forum.com/t/routes-sqlite3/172985/1 "2009-07-30T20:37:53Z")

</div>

I have two different questions, I hope that’s not a problem, if it is, I  
do two differents topics, sorry.

First, I would like to delete a table of sqlite3. The problem is that I  
had a table cathegories created, but I delete the code. Now I created a  
new model cathegories and when I do the rake, it says I already have the  
table cathegories created but I cannot use it I don’t know why, I cannot  
acces to that table with sqlite3…:S I think I could add a migration  
and drop table, migrate, and then start again with another migration  
creating columns, but I would like to delete the table from sqlite3 and  
then create from 0 the cathegories model.

Next issue is (important one) about asociations and routes.  
If I have comments that belongs to cathegory, the action would see like:

@post = Post.find(:post\_id)  
@comment = @post.comments.find(:id)

Ok, and in form\_for it would be like: form\_for([@post, @form])

Now, If I have a model cathegory and, obvious, posts belongs\_to  
cathegory. With a route

map.resources :cathegories :has\_many =\> {:posts =\> :comments}, :shallow  
=\> true

Then, Have I to do that? Is it correct?Is it necessary?:

@cathegory = Cathegory.find(:cathegory\_id)  
@post = @cathegory.posts.find(:post\_id)  
@comment = @post.comments.find(:id)

and the form: form\_for([@cathegory, @post, @comment]) ??  
Is that what I have to do?

With that route created, for example this routes would be ok?:

post\_path(@cathegory, @post)  
edit\_comment\_path(@cathegory, @post, @comment)

Yes, I’m a little bit (?) confused with the basics yet, I’m learning it  
now, and routes and asociations can make the life easier, but when you  
master it xD

Thank You very much

---

<div class="post-metadata">

**Author:** ![rubystudent](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/e9c0ed/32.png) [@rubystudent](https://www.ruby-forum.com/u/rubystudent)\
**Post date:** [July 31, 2009, 12:33am UTC](https://www.ruby-forum.com/t/routes-sqlite3/172985/2 "2009-07-31T00:33:38Z")

</div>

Protos J. wrote:

[…]

> First, I would like to delete a table of sqlite3. The problem is that I  
> had a table cathegories created, but I delete the code. Now I created a  
> new model cathegories and when I do the rake, it says I already have the  
> table cathegories created but I cannot use it I don’t know why, I cannot  
> acces to that table with sqlite3…:S

So you deleted the table from the DB, but Rails still thinks it’s there?  
If that’s the case, your schema.rb file is probably out of sync with the  
DB. Try rake db:schema:dump to fix it…and then use migrations to  
manipulate your DB in future, so that this won’t happen again!

> I think I could add a migration  
> and drop table, migrate, and then start again with another migration  
> creating columns, but I would like to delete the table from sqlite3 and  
> then create from 0 the cathegories model.

Migrations are the way to go.  
Also note correct spelling of “categories”.

## Best,

Marnen Laibow-Koser  
[http://www.marnen.org](http://www.marnen.org)  
removed\_email\_address@domain.invalid

---

<div class="post-metadata">

**Author:** ![rubystudent](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/e9c0ed/32.png) [@rubystudent](https://www.ruby-forum.com/u/rubystudent)\
**Post date:** [July 31, 2009, 8:32pm UTC](https://www.ruby-forum.com/t/routes-sqlite3/172985/3 "2009-07-31T20:32:57Z")

</div>

Thanks, but, about the first topic?

---

<div class="post-metadata">

**Author:** ![rubystudent](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/e9c0ed/32.png) [@rubystudent](https://www.ruby-forum.com/u/rubystudent)\
**Post date:** [July 31, 2009, 8:33pm UTC](https://www.ruby-forum.com/t/routes-sqlite3/172985/4 "2009-07-31T20:33:56Z")

</div>

Protos J. wrote:

> Thanks, but, about the first topic?

Sorry, I meant second
