Skip to content

olkeene/concerned_with

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ConcernedWith
=============

Simple way to separate model concerns into separate files. Code is from Rick Olson's altered_beast project.


Example
=======

== for Controllers

# app/controllers/application.rb
class ApplicationController < ActionController::Base
  concerned_with :rescues
end

# app/controllers/application_controller/rescues.rb
class ApplicationController < ActionController::Base
  rescue_from ActionController::RoutingError, :with => :route_not_found

  protected

  def route_not_found
    render :text => 'Page is not exist', :status => :not_found
  end
end


== for Models

# app/models/user.rb
class User < ActiveRecord::Base
  concerned_with :validations, :authentication
end

# app/models/user/validations.rb
class User < ActiveRecord::Base
  validates_presence_of :name
end

#app/models/user/authentication.rb
class User < ActiveRecord::Base
  def self.authenticate(name, password)
    find_by_name_and_password(name, password)
  end
end


Copyright (c) 2008 Jake Howerton, updated by Zhurbiy Oleg( Ol.keene ), released under the MIT license

About

Rails plugin to separate model concerns into multiple files.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Ruby 100.0%