Created
January 15, 2011 18:44
-
-
Save biagidp/781133 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#form | |
<%= form_for [@site, @detail] do |f| %> | |
<table id='amenities'> | |
<thead> | |
<th> Rank </th> | |
<th> Value </th> | |
</thead> | |
<%= f.fields_for :amenities do |af| %> | |
<tr> | |
<td><%= af.text_field :rank, :size => 1 %></td> | |
<td><%= af.text_field :value %></td> | |
<td><%= link_to "[X]", amenity_path(af.object), :method => 'delete', :remote => true %></td> | |
</tr> | |
<% end %> | |
</table> | |
<a href='' class='add_amenity' id="<%= @detail.amenities.count %>">New Amenity</a> | |
<br/> | |
<%= f.submit "Save Changes" %> | |
<% end %> | |
#controller action | |
def update | |
@site = current_site | |
if @site | |
@detail = @site.detail | |
else | |
@detail = Detail.find(params[:id]) | |
end | |
respond_to do |format| | |
if @detail.update_attributes(params[:detail]) | |
format.html { redirect_to(site_detail_path(@site), :notice => 'Details Updated!') } | |
format.js { render :layout => false} | |
else | |
format.html { redirect_to(site_detail_path(@site), :notice => 'Details Not Updated.') } | |
format.xml { head :ok } | |
end | |
end | |
end | |
#Routes | |
resources :sites do | |
resource :home_page | |
resource :detail | |
resource :calendar | |
resources :galleries | |
end | |
resources :sites, :home_pages, :galleries, :pictures, :details, :amenities, :calendars, :reservations | |
resource :detail do | |
resources :amenities | |
end | |
resources :calendars do | |
resources :reservations do | |
get 'confirm', :on => :member | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment