· 1 min read

Screencast: Resourcen vererben

Download:

Download(15.1 MB, 9:15) Alternativer Download für iPod & Apple TV(14.4 MB, 9:15)

Resourcen:

Quellcode:

[ruby] # Gemfile gem ‘inherited_resources’ gem ‘has_scope’

# products_controller.rb class ProductsController < InheritedResources::Base respond_to :html, :xml has_scope :limit, :default => 8 def create create! { products_path } end end

# reviews_controller.rb class ReviewsController < InheritedResources::Base belongs_to :product actions :index, :new, :create has_scope :rating def create create! { collection_url } end end

# models/review.rb scope :rating, proc { |rating| where(:rating => rating) } [/ruby]

[text] # config/locales/en.yml en: flash: actions: create: notice: “Your {{resource_name}} has been created!” [/text]

Back to Blog