I am trying to use the Padrino scheme in one of my projects, and there is one thing that really annoys me. I want to implement, for example, the process of registering users using OmniAuth and I want to split the request handler (controller action) to separate methods, for example:
get ": provider / callback" do
@user = find_the_user_by_oauth (request)
create_user unless @user
store_user_in_session
end
def find_the_user_by_oauth (request)
# ...
end
def store_user_in_session
session [: user_id] = @ user.id
end
I know that it would be better to push the logic to the model layer, but my question is how can I split the controller logic into divided methods and exchange information between them (for example, using instance variables). In Rails, I created these methods in a private area of my controller, but here I have to extend the Application class because it throws an Undefined method exception for the previous code. I tried Helpers, but helpers don't know instance variables, so you have to pass variables every time.
What is a good way to make my controller actions clean in Padrino?
source share