Created
May 7, 2012 16:25
-
-
Save scottweisman/2628768 to your computer and use it in GitHub Desktop.
Using current_kase method in views
This file contains hidden or 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
# concerns#current | |
module Current | |
extend ActiveSupport::Concern | |
... | |
def current_kase | |
@current_kase ||= Kase.find_by_id(params[:kase_id]) | |
end | |
# To include methods in views | |
def self.included m | |
return unless m < ActionController::Base | |
m.helper_method :current_user, :current_kase | |
end | |
end | |
# sources#controller | |
def index | |
# nothing here | |
end | |
# sources#index | |
<h1><%= current_kase.name %></h1> | |
<%= link_to "Add source", new_kase_source_path %> | |
<% if current_kase.sources.any? %> | |
<% current_kase.sources.each do |source| %> | |
<h3><%= link_to source.name, kase_source_path(current_kase, source) %></h3> | |
<% end %> | |
<% end %> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment