I have a template "groups/show.html.erb" I have link that renders a partial by passing a parameter to the controller. The controller then uses the parameter to identify which JS call to make.
<%= link_to 'Add a Video', group_path(create_video: true), remote: true %>
then in the controller
elsif params[:create_video]
@video = Group.find(params[:id]).videos.build
respond_to do |format|
format.js {render action: 'create_video'}
end
This brings up a partial with a form that creates a video using the create method in the videos_controller. If a validation on the form fails and I try to render "groups/show" I get a routing error:
_create_video.html.erb
<%= form_for @video, :url => group_videos_path(@group) do |f| %>
<%= f.text_field :name %>
<%= f.submit %>
<% end %>
No route matches {:action=>"show", :controller=>"groups", :create_video=>true}
To make this work I think you can just explicitly match it in routes.rb but is there a better way to do it? Thanks a bunch