Rendering a 'show' template with an additional parameter is causing a routing error

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])
  respond_to do |format|
    format.js {render action: 'create_video'}

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:


<%= 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


You are forgetting to give which group, you should normally do something like

group_path(@group, create_video: true)

hope this helps.

Need Your Help

CodeIgniter returns 404 for all routes but works

codeigniter-2 codeigniter-url

I have strange problem with CodeIgniter and routing system and can't find solution for it, so: I have several routes such as

Epoch vs. Date and time in mysql


I have simple question.