On Sat, May 22, 2010 at 5:23 AM, RubyonRails_newbie
<[email protected]> wrote:
>> You've writtten comments.create :id => params[:body] which I assume
>> isn't what you wanted.
>
> Well- i'd started to follow a tutorial, but didn't quite understand
> it.
> ANy idea what id should be to allow it to save?
>
> I've tried many combinations of the id, :user_id, body etc and when I
> change it, the null value shifts to the user_id, or the blogpost_id.
>
> I'm probably missing something really simple, but i was looking at
> this all last night! :-)
>
The id gets assigned automatically when a new record is saved, and
create saves the record.
def comment
@user = User.find(session[:user_id])
Blogpost.find(params[:id]).comments.create(:body =>
params[:body], :user => @user)
...
--
Rick DeNatale
Blog: http://talklikeaduck.denhaven2.com/
Github: http://github.com/rubyredrick
Twitter: @RickDeNatale
WWR: http://www.workingwithrails.com/person/9021-rick-denatale
LinkedIn: http://www.linkedin.com/in/rickdenatale
--
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 [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.