Here’s a basic one again.
I have 3 models:
class Program < ActiveRecord::Base
class Comment < ActiveRecord::Base
class User < ActiveRecord::Base
Comments contain the next info:
t.references :program t.references :user t.text :body t.timestamps
I implemented a RESTful app starting with programs and comments. And
later on I added Restful authentication ending up with the users object.
So now when I create a comment for a program I want to keep the data of
what user created that comment (that’s why I added the t.references :
user to the comments).
Everything is more or less ok but I don’t know to pass the user
reference when creating the comment. The user is known at the controller
via the current_user that the authentication plugin provides.
This is the form in the comments new.html.erb:
<% form_for([@program, @comment]) do |f| %>
<%= f.text_area :body %>
<%= f.submit "Create" %><% end %>
How to plug the user object that the create method expects?
I’ve tried hidden fields but didn’t manage to get it working.