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
| class Cart < ActiveRecord::Base | |
| has_many :line_items | |
| delegate :empty?, :to => :line_items | |
| end | |
| class User < ActiveRecord::Base | |
| has_one :cart | |
| end | |
| @user = User.new |
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
| if foo | |
| if bar | |
| something | |
| else | |
| something_else | |
| else | |
| baz |
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
| module Searchable | |
| def self.searchable_fields | |
| [] | |
| end | |
| def self.included(klass) | |
| klass.named_scope :by_search, lambda {|q, options| | |
| if q.present? | |
| search_text = [klass.searchable_fields].flatten.collect {|f| |
NewerOlder