Converted the Membership rate form to an Ajax remote form.
* Changed the form_for to be a remote_form_for * Changed the url to use the js format * Added RJS to add the Saved rate to the rate cell * Added id to the table cell so the rate cell can be replaced on success * Added an Error RJS to flash an error message #1921
This commit is contained in:
@@ -57,12 +57,19 @@ class RatesController < ApplicationController
|
||||
|
||||
respond_to do |format|
|
||||
if @rate.save
|
||||
flash[:notice] = 'Rate was successfully created.'
|
||||
format.html { redirect_back_or_default(rates_url(:user_id => @rate.user_id)) }
|
||||
format.html {
|
||||
flash[:notice] = 'Rate was successfully created.'
|
||||
redirect_back_or_default(rates_url(:user_id => @rate.user_id))
|
||||
}
|
||||
format.xml { render :xml => @rate, :status => :created, :location => @rate }
|
||||
format.js { render :action => 'create.js.rjs'}
|
||||
else
|
||||
format.html { render :action => "new" }
|
||||
format.xml { render :xml => @rate.errors, :status => :unprocessable_entity }
|
||||
format.js {
|
||||
flash.now[:error] = 'Error creating a new Rate.'
|
||||
render :action => 'create_error.js.rjs'
|
||||
}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user