This is the error:
No route matches {:action=>"send_to_client", :controller=>"stages"}
It corresponds to this line:
<%= link_to "<span class='icon send-to-client-icon' title='Send to Client' id='send-to-client'> </span>".html_safe, send_to_client_stage_path(@stage), :id => stage.id, :confirm => "This will send #{stage.name.capitalize} to #{stage.client.email}. Are you sure you are ready?" %>
In this _show_table.html.erb
<%
if @upload != nil
stage = @upload.stage
end
%>
<h1 class="panel-header">Images</h1>
<% if stage == nil %>
<div class="images_menu">
<%= link_to "<span class='icon send-to-client-icon' title='Send to Client' id='send-to-client'> </span>".html_safe, send_to_client_stage_path(@stage), :id => stage.id, :confirm => "This will send #{stage.name.capitalize} to #{stage.client.email}. Are you sure you are ready?" %>
<span class="icon compare-icon" data-url="<%= compare_stage_path(stage)%>" title="Compare Images" id="compare-images"> </span>
</div>
<% end %>
Here is my routes.rb:
resources :stages do
member do
get :step
get :compare
get :send_to_client
end
end
The issue is that this partial _show_table.html.erb is in the view folder of my uploads model…not the stages model.
When I execute that link_to in the stages model, it works fine. Once I take it out into the uploads model it throws that error.
Why would that be the case ?
Edit1: Here is the send_to_client action of the stages controller:
def send_to_client
stage = Stage.find(params[:id])
ClientMailer.send_stage(stage).deliver
if ClientMailer.send_stage(stage).deliver
flash[:notice] = "Successfully sent to client."
redirect_to("/")
else
flash[:notice] = "There were problems, please try re-sending."
redirect_to("/")
end
end
Rails will raise an ActionController::RoutingError if you use
send_to_client_stage_path(nil).You’re mixing up
@stageandstage. If you don’t define@stagein the controller action, it will beniland the error raises. In this case, just use@upload.stage.Like:
If you want to use
@stage, just define it in the action with@stage = @upload.stageand use it instead of@upload.stage: