module ApplicationHelper
def user_unauthorized?
...
end
end
class HomeController < ApplicationController
def index
redirect_to '/foo' if view_context.user_unauthorized?
end
end
Thursday, August 16, 2012
Share methods between controller and views in Rails
The key is to put methods into ApplicationHelper and call them in the controller
Subscribe to:
Post Comments (Atom)
Blog Archive
-
▼
2012
(42)
-
▼
August
(9)
- Add index on PostgreSQL table column for in-built ...
- Upgrade Heroku db to new PostgreSQL Dev addon
- Restarting crashed workers in Heroku
- Configure PostgreSQL full-text search using pg_sea...
- Run delayed jobs on Heroku with queue names
- Transfer domain from a Heroku Zerigo account to an...
- Share methods between controller and views in Rails
- Passing array of elements as multiple arguments in...
- Multiple heroku apps on different subdomains manag...
-
▼
August
(9)
No comments:
Post a Comment