huh... I get the same error.
Showing blog_posts/index.html.erb where line #17 raised:
undefined method `blog_post_path' for #<ActionView::Base:0x36f53d0>
huh... I get the same error.
Showing blog_posts/index.html.erb where line #17 raised:
undefined method `blog_post_path' for #<ActionView::Base:0x36f53d0>
huh... I get the same error.
Showing blog_posts/index.html.erb where line #17 raised:
undefined method `blog_post_path' for #<ActionView::Base:0x36f53d0>
Anything else I should do?
Kelly
Did you restart your server?
Also, type 'rake routes' to get a list of all the routing methods
generating by your routes definitions.
well I would like to always call my objects BlogPosts (or singular
BlogPost)
And I do want my table to be named something more than 'posts'
So blog_posts works great until you get to the URLs.
Too bad Rails leaves the underscore character in the URL.
Its funny, Grails has an issue around mulitword table names too.
In Grails the issue is camelcasing the URL.
So I would end up with a URL like this:
http://localhost/blogPost/
So what do you most people do in Rails.... avoid multi-word table
names?
Think I know how to fix this stuff now - hack the method names.
well I would like to always call my objects BlogPosts (or singular
BlogPost)
And I do want my table to be named something more than 'posts'
So blog_posts works great until you get to the URLs.
Too bad Rails leaves the underscore character in the URL.
Its funny, Grails has an issue around mulitword table names too.
In Grails the issue is camelcasing the URL.
So I would end up with a URL like this:
http://localhost/blogPost/
So what do you most people do in Rails.... avoid multi-word table
names?
In general - yes.
When I read you had a table called "blog_posts" my mind went immediately
to a Has And Belongs To Many association (HABTM), which joins two other
models - Blogs and Posts.
Not knowing much about the application you are writing it is difficult
to say for sure, but it appears you will be supporting multiple blogs
(one or more per user), each containing multiple posts. The models
would reflect this relationship and so therefore so would the tables in
the database.
eg.
----Models
class Blog < ActiveRecord::Base
has_many :posts
end
class Post < ActiveRecord::Base
belongs_to :blog
end
ok.... let me ask a really dumb question.
I'm really new to this.
So is the naming convention to never use an underscore unless you are
doing a
many-to-many relationship?
So if I wanted to work with BlogPost objects
Is the best method to call the table - blogposts
and the model - Blogpost ?
Should I give up on the idea of being able to have a
model called BlogPost (with the capital P)?
Seems like a major hassle.
The reason I'm asking is Post/Posts just seems so generic.
ok.... let me ask a really dumb question.
I'm really new to this.
That's OK - I am not an expert either, just a keen amateur.
So is the naming convention to never use an underscore unless you are
doing a
many-to-many relationship?
I don't think there is anything wrong with underscores (anyone?), but
the name itself is ambiguous to rails, hence the need for all the fancy
footwork to make the routes work.
So if I wanted to work with BlogPost objects
Is the best method to call the table - blogposts
and the model - Blogpost ?
Yes. This is closer to the conventions rails uses, which equates to
less work for you and more happiness.
Should I give up on the idea of being able to have a
model called BlogPost (with the capital P)?
The capital "P" in the model/table is not an issue. Neither is the name
until you get to exposing it to the user via a route. Rails expects the
mapping to be simple and straight forward. Since you are stepping away
from the conventions Rails is punishing you - it does that. Whenever
things seems difficult in Rails you are most likely running against the
grain.
I have found the easiest way is to name your controllers following what
you want the user to type. So /blog/ would require a "blogs"
controller. This makes the routes easy (map.resources blogs).
The models don't really matter that much, but you may want to have posts
belong to something else other than blogs at some stage in the future.
With a name like "blogposts" you kind of box yourself in.
Seems like a major hassle.
The reason I'm asking is Post/Posts just seems so generic.