Hello everyone, 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??? Many Thanks -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Craig Westmoreland wrote:> Hello everyone, > > I''d like to implement a blog on my site.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 http://github.com/mojombo/jekyll 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? :) -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
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 -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Devin M wrote:> 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 MHere: 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 :) -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Thanks! The API has some good examples. -Devin On Mar 1, 8:11 am, Aldric Giacomoni <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Devin M wrote: > > Anexampleof 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 :) > -- > Posted viahttp://www.ruby-forum.com/.-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.