I dont just mean to go to http://.../associates/list, but rather, so
that it acts just as it does normally in AS, with that div closing. -
Janna, Thanks!

On May 29, 7:41 pm, JannaB <[email protected]> wrote:
> Yes, sorry, I only had the conditional branching on the session
> variable in the update method. Sorry. The create method is as follows
> (I have marked off where I want to branch our from...so that I am back
> a http://.../associates/list:
>
> 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
>          #redirect_to where to from here per kenny?
> <--------------------------------------------------
>       else
>         #render :action => 'new'
>         render :action => 'new', :layout => 'other_layout'
>       end
>     end
>
> On May 29, 7:06 pm, Kenny Ortmann <[email protected]> wrote:
>
> > currently in your controller you have
>
> > def create
> >   @associate = Associate.new(params[:associate])
> >   @associate.startdate = Date.today
> >   if @associate.save
> >      flash[:notice] = "Registration successful."
> >      redirect_to root_url
> >    else
> >     #render :action => 'new'
> >          render :action => 'new', :layout => 'other_layout'
> >     end
> > end
>
> > This method says that after a create you want to redirect to the root url.
>
> > In your first email you said that after create or update you want it to
> > behave like active scaffold normally would correct?
>
> > so for instance you wouldn't want to redirect to root url?
>
> > On Fri, May 29, 2009 at 5:57 PM, JannaB <[email protected]> wrote:
>
> > > Kenny,
>
> > > Any thoughts on this? Thanks!
>
> > > On May 28, 10:51 am, JannaB <[email protected]> wrote:
> > > > Sure Kenny! (and thanks),
>
> > > > I have a login page, where the user (I call an 'Associate')
> > > > authenticates to. They can also, from that page, update their
> > > > Associate's record (with contact info, etc.). ADDITIONALLY, I am
> > > > letting administrators do a list, via AS, of Associates, and edit /
> > > > create from there (thus, I have the session variable 'fromlogin' to
> > > > determine where to route to, i.e., where they are coming from. If
> > > > fromlogin==0, I know it is the administrator in AS editing the record.
>
> > > > Here is my controller:
>
> > > > class AssociatesController < ApplicationController
> > > >   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,  :phonework,
> > > :phonehome, :phonecell, :phonefax,  :phoneother, :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,  :phonework,
> > > :phonehome, :phonecell, :phonefax,  :phoneother, :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[:phonework].description = "(Format: ###-###-####)"
> > > >       columns[:phonehome].description = "(Format: ###-###-####)"
> > > >       columns[:phonecell].description = "(Format: ###-###-####)"
> > > >       columns[:phonefax].description = "(Format: ###-###-####)"
> > > >       config.actions.exclude :show #, :delete
> > > >       config.actions.swap :search, :live_search
>
> > > >     end
>
> > > >     def setforlist
> > > >       session['fromlogin']=0
> > > >     end
>
> > > >           def new
> > > >               @associate = Associate.new
> > > >               render :action => 'new', :layout => 'other_layout'
> > > >           end
>
> > > >           def create
> > > >             @associate = Associate.new(params[:associate])
> > > >             @associate.startdate = Date.today
> > > >             if @associate.save
> > > >               flash[:notice] = "Registration successful."
> > > >               redirect_to root_url
> > > >             else
> > > >               #render :action => 'new'
> > > >               render :action => 'new', :layout => 'other_layout'
> > > >             end
> > > >           end
>
> > > >           def edit
> > > >             @associate = current_associate
> > > >             render :action => 'edit', :layout => 'other_layout'
> > > >             _get_states #forces state to be set when edit div
> > > > displayed
> > > >           end
>
> > > >           def update
> > > >             @associate = current_associate #Associate.find(params[:id])
> > > > #
> > > >             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
> > > >               end
> > > >               session['fromlogin']=0
> > > >             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 _get_states
> > > >      q = params[:country]
> > > >      # puts "******************"
> > > >      if(q==nil)
> > > >       �...@associate = current_associate
> > > >        [email protected]
> > > >      end
> > > >      #puts q
> > > >      if(q!=Carmen.default_country)
> > > >         q1 = q.gsub("_", " ")
> > > >         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 q
> > > >      #puts Carmen.default_country
> > > >      #puts "******************"
> > > >     @states =  Carmen::states(q)
> > > >    end
> > > > end
>
> > > > (p.s. I am using Authologic for authentication)
>
> > > > Here is my login view:
> > > > <% title "Login" %>
>
> > > > <% form_for @associate_session do |f| %>
> > > >   <%= f.error_messages %>
> > > >   <p>
> > > >     <%= f.label :username %><br />
> > > >     <%= f.text_field :username %>
> > > >   </p>
> > > >   <p>
> > > >     <%= f.label :password %><br />
> > > >     <%= f.password_field :password %>
> > > >   </p>
> > > >   <br />
> > > >   <%= f.check_box :remember_me %>
> > > >   <%= f.label :remember_me %><br />
> > > >   <br />
> > > >   <% session['fromlogin'] = 1 %>
> > > >   <p><%= f.submit "Submit" %></p>
> > > > <% end %>
>
> > > > Here is my Associates partial that gets called on new or edit:
>
> > > > <% form_for @associate do |f| %>
> > > >   <%= f.error_messages %>
> > > >   <p>
> > > >     <%= f.label :username %><br />
> > > >     <%= f.text_field :username %>
> > > >   </p>
> > > >   <p>
> > > >     <%= f.label :email %><br />
> > > >     <%= f.text_field :email %>
> > > >   </p>
> > > >   <p>
> > > >     <%= f.label :password %><br />
> > > >     <%= f.password_field :password %>
> > > >   </p>
> > > >   <p>
> > > >     <%= f.label :password_confirmation %><br />
> > > >     <%= f.password_field :password_confirmation %>
> > > >   </p>
> > > >   <p>
> > > >     <%= f.label :prefix %><br />
> > > >     <%= f.select( "prefix", [
> > > >     ["Mr." , "Mr."],
> > > >     ["Mrs.","Mrs."],
> > > >     ["Miss", "Miss"],
> > > >     ["Ms." ,"Ms."],
> > > >     ["Dr." , "Dr."],
> > > >     ["Hon.","Hon."],
> > > >     ["Fr. ", "Fr."]], {:include_blank => true})
> > > >       %>
> > > >   </p>
> > > >   <p>
> > > >      <%= f.label :firstname %><br />
> > > >      <%= f.text_field :firstname %>
> > > >   </p>
> > > >   <p>
> > > >      <%= f.label :middlename %><br />
> > > >      <%= f.text_field :middlename %>
> > > >   </p>
> > > >   <p>
> > > >      <%= f.label :lastame %><br />
> > > >      <%= f.text_field :lastname %>
> > > >   </p>
> > > >   <p>
> > > >      <%= f.label :street1 %><br />
> > > >      <%= f.text_field :street1 %>
> > > >   </p>
> > > >   <p>
> > > >      <%= f.label :street2 %><br />
> > > >      <%= f.text_field :street2 %>
> > > >   </p>
> > > >   <p>
> > > >      <%= f.label :city %><br />
> > > >      <%= f.text_field :city %>
> > > >   </p>
> > > >   <p>
> > > >     <%= f.label :state %><br />
> > > >   <select id="state" name="state">
> > > >     <option></option>
> > > >   <%= render :partial => 'get_states' %>
> > > >   </select>
> > > >   </p>
> > > >   <p>
> > > >       <%= f.label :postalcode %><br />
> > > >       <%= f.text_field :postalcode %>
> > > >    </p>
> > > >   <p>
> > > >   <%=
>
> ...
>
> 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