im on a users profile, ie the path is…
http://localhost:3000/users/2
i have a text field so the current user (me) can send a private message to user 2 while on his profile page.
how can i retrieve the users id and pass it in a hidden field?
<div><%= f.hidden_field :????, :value => ???? %></div>
thanks. the hidden tag field is in a form. here is the form if its helpful
<%= form_for(current_user.microposts.build(params[:micropost])) do |f| %>
<%= render 'shared/error_messages', object: f.object %>
<div class="field">
<%= f.text_area :content, placeholder: "Send a private message" %>
</div>
<div><%= f.hidden_field :private, :value => "true" %></div>
<%= f.submit "Post", class: "btn btn-large btn-primary" %>
<% end %>
thanks again
I would try having nested routes, e.g.
and then use
I try to avoid a hidden fields generally in rails, it usually means I’ve missed a convention.