Skip to content

Instantly share code, notes, and snippets.

@Amitesh
Created April 28, 2012 12:41
Show Gist options
  • Save Amitesh/2518775 to your computer and use it in GitHub Desktop.
Save Amitesh/2518775 to your computer and use it in GitHub Desktop.
Accessing Helper modules in rails
Accessing Helper modules in rails
http://www.funonrails.com/2010/12/accessing-helper-modules-in-rails.html
1. Helper methods all the time for views
class ApplicationController < ActionController::Base
helper :all# include all helpers, all the time for views
end
2. Controller methods in views
class ApplicationController < ActionController::Base
helper_method :current_store
#now controller_method can be accessed in views
end
2. Helper methods in controller
class ApplicationController < ActionController::Base
include ActionView::Helpers::ApplicationHelper
end
3. Helper methods in model
class Student < ActiveRecord::Base
include ActionView::Helpers::ApplicationHelper
end
4. Helper methods in mailer
class Notifier < ActionMailer::Base
add_template_helper(ApplicationHelper)
#...
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment