Rails开拓者改革:`初始化':未初始化的常量Uber :: Options(NameError)

时间:2017-01-29 20:31:20

标签: ruby-on-rails ruby reform trailblazer

我试图让Trailblazer-Rails在我的rails项目中工作。

但改革宝石似乎有些奇怪的事情发生了。

我无法使用" rails s"启动rails。 它回应错误:

" /home/dragonslayer/.rvm/gems/ruby-2.3.1/gems/reform-2.2.3/lib/reform/form/populator.rb:12:在`initialize':未初始化的常量Uber :: Options(NameError) "

但是当我删除合同时,它就有效。 当我删除conctract时,它有时似乎无法找到我的操作。

我的操作如下:

class GuildApplication::Create < Trailblazer::Operation

 step Model( GuildApplication, :new)
 step Contract::Build( constant: GuildApplication::Contract::Create)
 step Contract::Validate()
 step :set_status_to_pending
 step Contract::Persist()

 def set_status_to_pending(options)
  options["model"].status = :pending
 end
end

我的合同:

module GuildApplication::Contract
 class Create < Reform::Form

  property :first_name
  property :last_name
  property :email
  property :username
  property :server
  property :spec
  property :armory
  property :klass
  property :played
  property :klass_played
  property :bio
  property :raid_experience
  property :reason
  property :old_guild
  property :progress_raid
  property :attendance
  property :other

  property :screenshot, virtual: true

  extend Paperdragon::Model::Writer
  processable_writer :image
  property :image_meta_data

  validates :first_name, :last_name, :email, :username, :server, presence: true
  validates :screenshot, file_size: { less_than: 2.megabytes}, file_content_type: { allow: ['image/jpeg', 'image/png'] }
  validates_uniqueness_of :email
  validates_uniqueness_of :username
 end
end

我的控制器:

class GuildApplicationsController < ApplicationController

 def new
  render html: cell(GuildApplication::Cell::Register, nil, layout: Familylegion::Cell::LandingPage)
 end

 def create
  run GuildApplication::Create
 end
end

我的宝石文件:

source 'https://rubygems.org'

git_source(:github) do |repo_name|
  repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/")
 "https://github.com/#{repo_name}.git"
end

gem 'rails', '~> 5.0.1'
gem 'mysql2', '>= 0.3.18', '< 0.5'
gem 'puma', '~> 3.0'
gem 'sass-rails', '~> 5.0'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.2'
gem 'therubyracer', platforms: :ruby
gem 'jquery-rails'
gem 'turbolinks', '~> 5'
gem 'jbuilder', '~> 2.5'
#gem 'redis', '~> 3.0'
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'
gem 'rbattlenet'
gem 'slim'
gem "reform"
gem "reform-rails"
gem "trailblazer"
gem "trailblazer-rails"
gem "cells"
gem "cells-rails"
gem "trailblazer-cells"
gem 'cells-slim'
gem 'dry-validation'
gem 'semantic-ui-sass', github: 'doabit/semantic-ui-sass'
gem 'rmagick'
gem 'paperdragon'
gem 'file_validators'

gem 'capistrano-rails', group: :development

group :development, :test do
  gem 'byebug', platform: :mri
end

group :development do
 # Access an IRB console on exception pages or by using <%= console %>    anywhere in the code.
 gem 'web-console', '>= 3.3.0'
 gem 'listen', '~> 3.0.5'
 # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
 gem 'spring'
 gem 'spring-watcher-listen', '~> 2.0.0'
end

1 个答案:

答案 0 :(得分:2)

这个问题在改革2.2.4中已经修复,见https://github.com/trailblazer/reform/issues/422