Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # after doing an edit via update, it won't redirect_to show, it stays on edit, I am using ajax
- # in the view
- # so here is the code:
- #
- # here is how I have the routes:
- map.resources :patrocinios
- #...
- map.connect ':controller/:action/:id'
- map.connect ':controller/:action/:id.:format'
- # here is the controller:
- def edit
- @patrocinio = Patrocinio.find(params[:id])
- respond_to do |format|
- format.html # edit.html.erb
- format.xml { render :xml => @patrocinio }
- end
- end
- def update
- @patrocinio = Patrocinio.find(params[:id])
- respond_to do |format|
- if @patrocinio.update_attributes(params[:patrocinio])
- flash[:notice] = 'Patrocinio was successfully updated.'
- format.html { redirect_to(@patrocinio) }
- format.xml { head :ok }
- else
- format.html { render :action => "edit" }
- format.xml { render :xml => @patrocinio.errors, :status => :unprocessable_entity }
- end
- end
- end
- # here is the view:
- <h1>Editing Patrocinio: <%= @patrocinio.id %> </h1>
- <% form_remote_for(@patrocinio) do |f| %>
- <%= f.error_messages %>
- <p>
- <%= f.label :logotipo_id %><br />
- <%= f.select :logotipo_id, @logotipos, :prompt => "Select one..." %></td>
- </p>
- <p>
- <%= observe_field( :patrocinio_logotipo_id,
- :url => { :action => :update_image_div },
- :frequency => 1.0,
- :update => 'logo_field_div',
- :with => :logotipo_id ) %>
- <div id='logo_field_div'>
- </div>
- </p>
- <p>
- <%= f.submit 'Update' %>
- </p>
- <% end %>
Add Comment
Please, Sign In to add comment