I have two hidden_fields, user_id and skill_id
<%= form_for @skill do |s| %>
<%= s.label :image, "Upload your skill" %>
<%= s.hidden_field :user_id, value: current_user.id %>
<%= s.hidden_field :skill_id, value: params[:id] %>
<%= s.file_field :image, multiple: true %>
<% end %>
In my controller I have this:
def reviews
@skill = Skill.new
end
I'm able to get the value for skill_id into my database, but I'm not able to get the value from user_id. In my rails console, I see that user_id is being passed through "skill", but doesn't show in my database.
Parameters: {"utf8"=>"✓", "authenticity_token"=>"5+wxS929uxtt..", "skill"=>{"user_id"=>"7", "skill_id"=>"132", ...
I even checked to see if I'm getting any value with <%= current_user.id %>, which I am.
Maybe someone can guide me to the right path in debugging this issue.
Thanks
"user_id"=>""in your params that is why it is not getting passed to database.user_idset in theattr_accessible? Also I am assuming that askillbelongs to auser. Why not just use@skill=current_user.skills.newin your controller?