I want my page to refresh once a record has been created, at the moment it directs it to the page before. here is the code from my controller:
def create
@license = License.new(params[:license])
respond_to do |format|
if @license.save
format.html { redirect_to :controller => 'customers', :action => 'index' }
format.json { render json: @customer, status: :created, location: @customer }
else
format.html { render action: "new" }
format.json { render json: @customer.errors, status: :unprocessable_entity }
end
end
where it says redirect_to i need that to refresh, or link to the current page, with the current id, which would be :controller => 'customers', :action => 'show' but with the id of the current page’s record.
Try
instead.
Depending on what your routes.rb file says, it should work.
But if it doesn’t, try:
However, here I have to assume that somehow, your customers_controller.rb is somehow showing records from the License model. If License and Customer are separate models, you will have to find the customer_id in some other way.
Perhaps, it is:
If License is not connected to Customer in any way, you will need to pass it in as part of the post request.