Passing values through params in a form
Think this is a pretty basic question but I've been racking my brain for a
long time trying to get this to work.
In a view, i defined a variable. This works and results in the value I'm
trying to get at (the users id, which is 1).
<% tripowner = User.find_by_id(@trip.userid).id %>
In a form down below on the page I am trying to pass this value through
the params so I can do stuff with it in the action. My goal is to pass
this 1 in the tripowner variable into the params.
<%= hidden_field_tag :tripowner %>
Finally, I am trying to do something with this value in an action in the
controller.
@friendship.f2 = params[:tripowner]
My goal is to make @friendship.f2 = 1, but it is returning nil.
Am i missing something basic / is this possible?
Note : tripowner is not a column in any database table. I just defined
this variable on the view page itself to return a Number I want.
No comments:
Post a Comment