I am struggling with the following architectural problem:

My app right now has 2 singular resources: user and user_session
(authlogic-based), with appropriate controllers. I have a landing page
that has on it both the "Sign in" form and the "Create new user/Sign
up" form. Both forms point to the :create action of the corresponding
resource controller. The landing page is served by LandingController
with a :index action.

I am not sure what is the appropriate way to implement the :create
actions. Specifically, I am not sure what to do in case of an error:
ideally, I would like to render the landing page with errors, but the
default is to render the :new action, which I don't have, and I could
implement them, but I am aiming to create just one page. Is what I am
doing completely counter to the way Rails expects these things to be
done?

 Right now, the UserController.create is:

def create
    @user = User.new(params[:user])
    respond_to do |format|
      if @user.save!
        format.html { redirect_to(@user) }
      else
        format.html { render :action => "new" }
      end
    end
end

The UserSessionController is:
  def create
    @user_session = UserSession.new(params[:user_session])
    if @user_session.save
      redirect_to_stored_or_default
    else
      render :new
    end
  end

--

You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" 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/rubyonrails-talk?hl=en.


Reply via email to