Thank you so much Sergio. I think I have a much better understanding
now! -Janna B.

On Jun 5, 7:17 pm, <[email protected]> wrote:
> On Fri, 5 Jun 2009 14:18:18 -0700 (PDT), JannaB <[email protected]>
> wrote:
>
> > Sergio,
>
> > Yes, I am using Rails 2.3, latest checkout of AS that is a stable
> > checkout (a day or two old). Even when I rem out the redirect_to's in
> > my update method, it still doesn't execute update_respond_to_html
>
> update_respond_to_html is called from respond_to_action, which is called in
> the update method from active_scaffold. As you have overridden the update
> method, really is not an ActiveScaffold issue, you have redirect_to
> '/associates/' there, so you only have to change it to redirect_to
> request.referer and you will go to previous page.
>
> Anyway, you don't need to override so much ActiveScaffold methods usually,
> using ActiveScaffold configuration, overriding
> #{action}_respond_to_#{format} methods and using
> before_(update|create)_save and after_(update|create)_save callbacks is
> often enough. I don't know if you are using too much ActiveScaffold in this
> controller. Also, you can add before_filters to execute some code before
> actions, for example you can add "before_filter :get_states, :only =>
> [:new, :edit]", and other before_filters to set @associate, instead of
> override ActiveScaffold actions.
>
>
>
>
>
> > On Jun 5, 12:12 pm, "Sergio Cambra .:: entreCables S.L. ::."
> > <[email protected]> wrote:
> >> Are you using rails 2.3 and ActiveScaffold from master branch?
> >> update_respond_to_html is only in rails 2.3. Also, you have update
> method
> >> override, and there you redirect to /associated
> >> rgio
> >> On Viernes, 5 de Junio de 2009 15:51:07 JannaB escribió:
>
> >> > Ok, but she's a BIG baby:
>
> >> > class AssociatesController < ApplicationController
> >> >   #before_filter :require_no_user, :only => [:new, :create]
> >> >   #before_filter :require_user, :only => :destroy
> >> >   before_filter :require_associate, :only =>
> >> > [:index, :show, :list, :edit, :update, :delete, :destroy, :search]
> >> >   before_filter :setforlist, :only => [:index, :show, :list]
>
> >> >   active_scaffold :associate do |config|
> >> >        config.label = "Associates"
>
> >> >       config.create.columns =
> >> > [:username, :email, :prefix, :firstname, :middlename, :lastname,
> >> > :street1,
> >> > :street2, :city,  :state, :postalcode, :country, :phone1, :phone2,
> >> > :phone3,
> >> > :jobtitle, :organization,  :startdate, :dob,  :ssno,
> >> >  :maritalstatus,
> >> > :password, :custom1, :custom2,  :custom3, :custom4,  :branch, :notes
> >> > ]
> >> > config.update.columns =
> >> > [:username, :email, :prefix, :firstname, :middlename, :lastname,
> >> > :street1,
> >> > :street2, :city,  :state, :postalcode, :country, :phone1, :phone2,
> >> > :phone3,
> >> > :jobtitle, :organization,  :startdate, :dob,  :ssno,
> >> >  :maritalstatus,
> >> > :password, :custom1, :custom2,  :custom3, :custom4,  :branch, :notes
> >> > ]
> >> > config.list.columns  =
> >> > [:lastname, :firstname, :username, :email, :branch]
>
> >> >         #list.columns.exclude :comments
> >> >         config.columns[:state].form_ui = :usa_state
> >> >         config.columns[:country].form_ui = :country
> >> >         list.sorting = {:lastname => 'ASC'}
> >> >         #columns[:phone].label = "Phone #"
> >> >         columns[:phone1].description = "(Format: ###-###-####)"
> >> >         columns[:phone2].description = "(Format: ###-###-####)"
> >> >         columns[:phone3].description = "(Format: ###-###-####)"
> >> >         config.actions.exclude :show #, :delete
> >> >       config.actions.swap :search, :live_search
> >> >     end
>
> >> >     def update_respond_to_html
> >> >       puts "yakkkk"
> >> >       puts params[:iframe]
> >> >       if params[:iframe]=='true' # was this an iframe post ?
> >> >         responds_to_parent do
> >> >           if successful?
> >> >             render :action => 'on_update.js'
> >> >           else
> >> >             render :action => 'form_messages_on_update.js'
> >> >           end
> >> >         end
> >> >       else # just a regular post
> >> >         if successful?
> >> >           flash[:info] = as_(:updated_model, :model =>
> >> > @record.to_label)
> >> >           return_to_main
> >> >         else
> >> >             render(:action => 'update')
> >> >         end
> >> >       end
> >> >     end
>
> >> >     def setforlist
> >> >       session['fromlogin']=0
> >> >     end
>
> >> >     def new
> >> >         get_states #forces state to be set when edit div displayed
> >> >         @associate = Associate.new
> >> >         render :action => 'new', :layout =>
> >> > 'other_layout'
> >> >     end
>
> >> >     def create
> >> >       params[:associate][:state]=params['state']
> >> >       @associate = Associate.new(params[:associate])
> >> >       set_branch_code
> >> >       if @associate.save
> >> >         if(session['fromlogin']!= nil && session['fromlogin']
> >> > ==1)
> >> >           flash[:notice] = "Registration successful."
> >> >           redirect_to root_url
> >> >          end
> >> >          session['fromlogin']=0
> >> >          do_list    #re-sort, etc from active_scaffold/lib/
> >> > active_scaffold/actions/list.do_list
> >> >          render(:action => 'list', :id => nil)
> >> >       else
> >> >         #render :action => 'new'
> >> >         render :action => 'new', :layout => 'other_layout'
> >> >       end
> >> >     end
>
> >> >     def edit
> >> >       get_states #forces state to be set when edit div displayed
> >> >       @associate=the_associate
> >> >       render :action => 'edit', :layout => 'other_layout'
> >> >       _get_states #forces state to be set when edit div
> >> > displayed
> >> >     end
>
> >> >     def update
> >> >       @associate=the_associate
> >> >       set_branch_code
> >> >       params[:associate][:state]=params['state']
> >> >       if @associate.update_attributes(params[:associate])
> >> >         flash[:notice] = "Successfully updated profile."
> >> >         #puts session['fromlogin']
> >> >         if(session['fromlogin']!= nil && session['fromlogin']
> >> > ==1)
> >> >             redirect_to root_url
> >> >             session['fromlogin']=0
> >> >             return
> >> >         end
> >> >         session['fromlogin']=0
> >> >         do_list    #re-sort, etc from active_scaffold/lib/
> >> > active_scaffold/actions/list.do_list
> >> >         #render(:action => 'list', :id => nil)
> >> >         redirect_to   "/associates/"
> >> >       else
> >> >         render :action => 'edit', :layout =>
> >> > 'other_layout'
> >> >         #render :action => 'edit'
> >> >       end
> >> >     end
>
> >> >     def do_destroy
> >> >       associate = Associate.find(params[:id])
> >> >       self.successful = associate.update_attributes(:deleted => -1)
> >> >     end
>
> >> >     def the_associate
> >> >       if(session['fromlogin']!= nil && session['fromlogin']==1)
> >> >           return current_associate
> >> >         else
> >> >           if params[:id]=="current"
> >> >               return current_associate
> >> >           else
> >> >               return Associate.find(params[:id])
> >> >           end
> >> >         end
> >> >     end
>
> >> >     def _get_states
> >> >       @associate = the_associate
> >> >       get_states
> >> >     end
>
> >> >    def get_states
> >> >      q = params[:country]
> >> >      #puts "******************"
> >> >       if(q==nil)
> >> >         @associate = the_associate
> >> >         if(@associate==nil)
> >> >           q=Carmen.default_country
> >> >         else
> >> >           [email protected]
> >> >         end
> >> >       end
> >> >       #puts q
> >> >       if(q!=Carmen.default_country)
> >> >          q1 = q.gsub("_", " ")
> >> >          q.capitalize!
> >> >          if(q1!=q && q1!=nil)
> >> >              q = q1.titleize #q1.split(' ').map {|w|
> >> > w.capitalize }.join(' ')
> >> >          #else
> >> >          #    q.capitalize!
> >> >          end
> >> >          q = Carmen::country_code(q)
> >> >       end
> >> >       #puts Carmen.default_country
> >> >       #puts q
> >> >       #puts (Carmen::states(q)).length
> >> >       #puts "******************"
> >> >     �...@states =  Carmen::states(q)
> >> >    end
>
> >> >    def set_branch_code
> >> >      if @associate.branch==nil
> >> >       �[email protected]="pending"
> >> >      else
> >> >        if(params['xbranch']!=nil)
> >> >          if @associate.lbranch==""
> >> >           �[email protected]=(params['xbranch']).to_s
> >> >          else
> >> >           �[email protected]=(@associate.lbranch).to_s + (params
> >> > ['xbranch']).to_s
> >> >          end
> >> >        end
> >> >      end
> >> >    end
>
> >> > end
>
> >> > On Jun 5, 3:34 am, "Sergio Cambra .:: entreCables S.L. ::."
>
> >> > <[email protected]> wrote:
> >> > > On Jueves, 4 de Junio de 2009 17:45:21 JannaB escribió:
> >> > > > Hmmm, I have....and it is never getting  invoked?
>
> >> > > Please, post your controller
>
> >> > > > On Jun 4, 11:21 am, "Sergio Cambra .:: entreCables S.L. ::."
>
> >> > > > <[email protected]> wrote:
> >> > > > > On Jueves, 4 de Junio de 2009 16:08:30 JannaB escribió:
> >> > > > > > Can I override that in my controller? I only need it to work
> >> > > > > > with
> >> > > > > > one controller/model/view slice, not the whole application.
> >> > > > > > -JannaB
>
> >> > > > > Yes you must override it in your controller. Put it below
> >> > > > > active_scaffold configure block
>
> >> > > > > > On Jun 4, 5:56 am, "Sergio Cambra .:: entreCables S.L. ::."
>
> >> > > > > > <[email protected]> wrote:
> >> > > > > > > On Miércoles, 3 de Junio de 2009 22:47:43 JannaB escribió:
> >> > > > > > > > The problem is that it occurs in
>
> >> > > > > > > > Associates.update
>
> >> > > > > > > > Which reroutes me back to the associates table. There has
> >> > > > > > > > to be
> >> > > > > > > > a way in Associates.update that I can have it do nothing
> >> > > > > > > > with
> >> > > > > > > > the view?
>
> >> > > > > > > You must to override update_respond_to_html in order to
> >> > > > > > > redirect
> >> > > > > > > to request.referer for example.
>
> >> > > > > > > > On
>
> ...
>
> read more »
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"ActiveScaffold : Ruby on Rails plugin" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/activescaffold?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to