Created
February 1, 2016 00:46
-
-
Save Yorkshireman/5aa2ad5971e4210cd1bd to your computer and use it in GitHub Desktop.
PadrinoBlog users controller pre-refactor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PadrinoBlog::App.controllers :users do | |
get :new do | |
@user = User.new | |
render 'users/new' | |
end | |
post :create do | |
user = User.new(params[:user]) | |
if user.save | |
redirect('/sessions/new', notice: "Signed up successfully! Please Log in") | |
elsif (params[:user][:password_confirmation] != "") && (params[:user][:password] != params[:user][:password_confirmation]) | |
redirect('/users/new', notice: "Password and Password Confirmation do not match. Please try again.") | |
else | |
redirect('/users/new', notice: "Please make sure you fill in all fields.") | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For example:
This won't work.
How do I refactor stuff out into methods? I can create external helper modules with methods inside them, and then include that module here and call its methods, but I'd rather not do that.
I'm thinking along the lines of Rails controllers, how you just refactor stuff out into private methods in the controller class. I want to do something similar here, but obviously I can't.