One form is to create a new user, the other is to create a new user
session. The two forms should post to their respective create actions.
In the error case, you could still instantiate a blank user session
and a blank user so that when you render :template => "users/new"
the
template doesn''t barf on not having all its variables ready.
On Dec 2, 12:37 am, Yuri
<yuri.niya...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:> 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
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.