You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
class Comment < ActiveRecord::Base
class Create < Trailblazer::Operation
include CRUD
model Comment, :create
contract do
property :body
property :weight
property :thing
validates :body, length: { in: 6..160 }
validates :weight, inclusion: { in: ["0", "1"] }
validates :thing, :user, presence: true
property :user do
property :email
validates :email, presence: true, email: true
end
end
def process(params)
validate(params[:comment]) do |f|
f.save
end
end
private
def setup_model!(params)
model.thing = Thing.find_by_id(params[:thing_id])
end
end
end
config/initializers/trailblazer.rb
require 'trailblazer/autoloading'
require "trailblazer/operation/dispatch"
Trailblazer::Operation.class_eval do
include Trailblazer::Operation::Dispatch
end
require "roar/decorator"
require "roar/json/hal"
::Roar::Representer.module_eval do
include Rails.application.routes.url_helpers
# include Rails.app.routes.mounted_helpers
def default_url_options
{}
end
end
The text was updated successfully, but these errors were encountered:
Hi, are you reading the most recent version? CRUD has been renamed to Model and I'm a 100% sure I changed all occurrences in the book, many months ago. Let me know if that doesn't fix it for you.
I am follow chapter 5 of the book
app/concepts/comment/operation.rb
config/initializers/trailblazer.rb
The text was updated successfully, but these errors were encountered: