Jesse Crockett wrote:
Instead of the user entering a name, I want to pass their screen name
along with supplied :title and :content fields. here is what I've
f.hidden_field :author, user.screen_name
here is the create method from Posts controller:
@title = "Gravity"
@user = User.find(params[:id]) # this does not work, and I don't
if request.post? and params[:post]
flash[:notice] = "Comment created"
redirect_to :action => "index"
flash[:notice] = "Please complete all fields"
redirect_to :action => "create"
I would need more information but I'll try to guess, and since you are
using f.hidden_field you should have a form declaration related to a
particular object (let's say "comment"). In that case your author
information should be accessible through params[:comment][:author] in
That means you should change the line
@user = User.find(params[:id])
@user = User.find_by_screen_name(params[:comment][:author])
Don't forget to change :comment by the good name. If not, then give us