1

I'm doing an app with session management and I want to display if the user is logged in or not at the top of every page. I have the front-end for this in application.rhtml.erb, is there any controller/method that will let me set a site-wide variable? As it is I define the condition for every individual page, there has to be a better way.

1

1 Answer 1

1

Put your method in the application_helper.rb file. That'll be available site-wide.

Sign up to request clarification or add additional context in comments.

1 Comment

application_helper.rb will only affect views, I believe. I think you want to add code to application_controller.rb if you want it to be available from all other controller. If you also want it to be available in views, add a line after the method definition helper :my_method. See a good post on this here: stackoverflow.com/questions/3549713/controller-helper-method

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.