So, my form is partially loaded in my div id="secondary" , which is hidden when loading the first page.
When a user clicks a button with a class called toggleSidebar , toggleSidebar is displayed.
I redefined partial to display the new form (even if I click update ) when the user did not log in as follows:
<%= simple_form_for(Post.new, html: {class: 'form-horizontal' }) do |f| %>
Unlike the regular version, which looks like this and is included in the if in the same partial:
<% if current_user and current_user.has_any_role? :editor, :admin %> <%= simple_form_for(@post, html: {class: 'form-horizontal' }) do |f| %>
The real problem in my opinion when someone goes to update is what happens when the user logs out:
<%= link_to "Update", "#", class: "togglesidebar" %>
This is great, it does CSS, and it shows the blank form perfectly.
However, when the user is logged in, I want him to send the parent_id: @post when starting the sidebar.
This looks with the usual new_post_path (i.e. the new postbar view):
<% if current_user %> <%= link_to "Update", new_post_path(parent_id: @post) %> <% end %>
This is what my PostController#New looks like:
def new @post = Post.new(parent_id: params[:parent_id]) end
How can I pass parameters in the regular version not new_post_path or solve this other way?