ruby-on-railsrubyreformtrailblazer

Rails Trailblazer Reform: `initialize': uninitialized constant Uber::Options (NameError)


Im trying to get Trailblazer-Rails to work in my rails project.

But there seem to be some weird things going on with the reform gem.

I cant start rails with "rails s". It responds with the error:

"/home/dragonslayer/.rvm/gems/ruby-2.3.1/gems/reform-2.2.3/lib/reform/form/populator.rb:12:in `initialize': uninitialized constant Uber::Options (NameError) "

but when i remove my contract, it works. When i remove the conctract it sometimes seem to not be able to find my Operation.

My operation looks like this:

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

My contract:

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

My Controller:

class GuildApplicationsController < ApplicationController

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

 def create
  run GuildApplication::Create
 end
end

My gemfile:

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

Solution

  • This issue is fixed in reform 2.2.4, see https://github.com/trailblazer/reform/issues/422 .