I am using rails 2.3.8 and I’ll load a modal dialog box using a partial called _show_venue.html.erb. Inside this partial I add link_to_remote to edit each venue.
_show_venue.html.erb ::
<table>
<tr>
<th>Country</th>
<th>Place</th>
<th>Color</th>
</tr>
<% @venues.each do |venue| %>
<tr>
<td><%=h venue.country_id %></td>
<td><%=h venue.place %></td>
<td><%=h venue.color %></td>
<td><%= link_to_remote 'Edit', :url => {:controller => 'venues', :action => 'edit', :id=>venue.id } %></td>
</tr>
<% end %>
</table>
And this is my controller code ::
def edit
@venue = Venue.find(params[:id])
end
edit.js.rjs ::
page.replace_html 'edit_venue', :partial => 'edit_form'
page<< "$j ('#event_actions').dialog({
title: 'Edit venue
modal: true,
width: 500,
close: function(event, ui) { $j ('#event_actions').dialog('destroy') }
});"
But when I run this, it could not find edit.js.rjs file. Why did this happen? Anyone can explain it?
You should do the following changes to you controller method:
so that it will find the edit.js.rjs and render it.
Edit: The 404 HTTP status which was the main problem was because of a missing route.
A route to match venues/:id/edit should solve the problem.