On Mon, Mar 3, 2014 at 4:01 PM, Brandon <wongwf82@gmail.com> wrote:
> This is what my User/Create looks like after rethinking my controller. Does
> it need more work to make it slimmer?
I've seen (and even made) much worse, but this can be slimmed down
fairly easily. The sign_in and that big if-statement, have nothing to
do with what screen to show next, data to show there other than what's
already in some already-used model, or other such things that properly
belong in the controller. So, they can be extracted and put into the
User model, though you may need to pass in the current_order_id and
current_follow_id. You'd wind up with something like:
def create
user.updating_password = true
if user.save
user.process_initial_session(current_order_id, current_follow_id)
redirect_back_or root_url, flash => { :success => 'Welcome!' }
else
render 'new'
end
end
where user.process_initial_session (or whatever you choose to call it;
could be welcome, set_up_stuff, link_to_order_or_followers, whatever,
depending what else you may want to put in it) encapsulates all that
extracted stuff.
-Dave
--
Dave Aronson, the T. Rex of Codosaurus LLC (www.codosaur.us);
FREELANCE SOFTWARE DEVELOPER, AVAILABLE AS OF MARCH 1st 2014;
creator of Pull Request Roulette, at PullRequestRoulette.com.
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAHxKQiimofZaZKBgzDgUVJM%2B3n53OzHE%3DPa3yyGJbZdCGTDkPw%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.
No comments:
Post a Comment