I'd like to implement a blog on my site.
I can do this easily enough using the built in scaffolding, and then
amend it accordingly.
However, I'd quite like users to be able to comment on blogs, and to
allow for user's to be stored in the database. In my head I have a
blogs table with the following columns
id
title
body
user_id
created_at
updated_at
From here, each time i create a blog, the user_id from the session is
placed in the table.
All good,
I would quite like the ability for users to then comment on a post
once logged in.
Has anyone done this. or know of a good tutorial that covers this?
On a side note:
At present the user_id is not being set in the blog table. Any reason
for this???
Blogs in Ruby and/or Rails are pretty much the most common sample app,
if you except the depot application. I'm not sure why you intend on
reinventing the wheel. If your goal is to have a functional blog, take a
look at GitHub - jekyll/jekyll: 🌐 Jekyll is a blog-aware static site generator in Ruby or do a quick search for "ruby
blog" online. If your goal is to develop your skills, ...
First, a blog is a collection of posts, so when you say "each time I
create a blog", do you mean "each time you create a post" ?
Secondly, if the user_id is not being set in the blog table, maybe you
could show us some code?
An example of relationships between models would be appricated. I am
trying to use a post and comment system as well and have my models set
up so a post has_many :comments and a comment belongs_to :post. Is
there any examples for these types of relationships? Im new to ruby
and just trying to get the basics down.
An example of relationships between models would be appricated. I am
trying to use a post and comment system as well and have my models set
up so a post has_many :comments and a comment belongs_to :post. Is
there any examples for these types of relationships? Im new to ruby
and just trying to get the basics down.
Thanks,
Devin M
Here: http://railsbrain.com/api/rails-2.3.2/doc/index.html
On the left, enter "has_many" and take a look at the documentation. It's
got a lot of examples-- and if you don't understand these, then we'll
explain them to you