fae icon indicating copy to clipboard operation
fae copied to clipboard

Not compatible with Rails 5.0

Open LeChin opened this issue 10 years ago • 11 comments

Looking into a solution for a personal project. Rails 4.1 is the version it's locked at.

LeChin avatar Jul 24 '16 01:07 LeChin

Yup, looking to get Rails 5 support in place by the launch of the microsite.

jamesmk avatar Jul 24 '16 05:07 jamesmk

Ok, what's the timeline for that? I'd be interested in learning how multi-Rails version support works.

LeChin avatar Jul 24 '16 16:07 LeChin

Getting all the tests to pass would be the first step. If you want to take a crack at it, I can show you how to setup appraisal to run the test suite on the Rails 5.

jamesmk avatar Jul 25 '16 05:07 jamesmk

Hey guys!

I got a jump start on this in the rails-5 branch. It would appear that remotipart needs to be upgraded, as well as any gem that uses ActionDispatch::ParamsParser.

Stack trace for reference:

bundler: failed to load command: rspec (/Users/Tim/.rvm/gems/ruby-2.3.1@fae/bin/rspec)
RuntimeError: No such middleware to insert after: ActionDispatch::ParamsParser
  /Users/Tim/.rvm/gems/ruby-2.3.1@fae/gems/actionpack-5.0.0/lib/action_dispatch/middleware/stack.rb:108:in `assert_index'
  /Users/Tim/.rvm/gems/ruby-2.3.1@fae/gems/actionpack-5.0.0/lib/action_dispatch/middleware/stack.rb:80:in `insert_after'
  /Users/Tim/.rvm/gems/ruby-2.3.1@fae/gems/railties-5.0.0/lib/rails/configuration.rb:69:in `block in merge_into'
  /Users/Tim/.rvm/gems/ruby-2.3.1@fae/gems/railties-5.0.0/lib/rails/configuration.rb:68:in `each'
  /Users/Tim/.rvm/gems/ruby-2.3.1@fae/gems/railties-5.0.0/lib/rails/configuration.rb:68:in `merge_into'
  /Users/Tim/.rvm/gems/ruby-2.3.1@fae/gems/railties-5.0.0/lib/rails/engine.rb:507:in `block in app'
  /Users/Tim/.rvm/gems/ruby-2.3.1@fae/gems/railties-5.0.0/lib/rails/engine.rb:504:in `synchronize'
  /Users/Tim/.rvm/gems/ruby-2.3.1@fae/gems/railties-5.0.0/lib/rails/engine.rb:504:in `app'
  /Users/Tim/.rvm/gems/ruby-2.3.1@fae/gems/railties-5.0.0/lib/rails/application/finisher.rb:37:in `block in <module:Finisher>'
  /Users/Tim/.rvm/gems/ruby-2.3.1@fae/gems/railties-5.0.0/lib/rails/initializable.rb:30:in `instance_exec'
  /Users/Tim/.rvm/gems/ruby-2.3.1@fae/gems/railties-5.0.0/lib/rails/initializable.rb:30:in `run'
  /Users/Tim/.rvm/gems/ruby-2.3.1@fae/gems/railties-5.0.0/lib/rails/initializable.rb:55:in `block in run_initializers'
  /Users/Tim/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/tsort.rb:228:in `block in tsort_each'
  /Users/Tim/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component'
  /Users/Tim/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/tsort.rb:431:in `each_strongly_connected_component_from'
  /Users/Tim/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/tsort.rb:349:in `block in each_strongly_connected_component'
  /Users/Tim/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/tsort.rb:347:in `each'
  /Users/Tim/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/tsort.rb:347:in `call'
  /Users/Tim/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/tsort.rb:347:in `each_strongly_connected_component'
  /Users/Tim/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/tsort.rb:226:in `tsort_each'
  /Users/Tim/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/tsort.rb:205:in `tsort_each'
  /Users/Tim/.rvm/gems/ruby-2.3.1@fae/gems/railties-5.0.0/lib/rails/initializable.rb:54:in `run_initializers'
  /Users/Tim/.rvm/gems/ruby-2.3.1@fae/gems/railties-5.0.0/lib/rails/application.rb:352:in `initialize!'
  /Users/Tim/localserver/fae/spec/dummy/config/environment.rb:5:in `<top (required)>'
  /Users/Tim/localserver/fae/spec/spec_helper.rb:3:in `require'
  /Users/Tim/localserver/fae/spec/spec_helper.rb:3:in `<top (required)>'
  /Users/Tim/localserver/fae/spec/rails_helper.rb:1:in `require'
  /Users/Tim/localserver/fae/spec/rails_helper.rb:1:in `<top (required)>'
  /Users/Tim/.rvm/gems/ruby-2.3.1@fae/gems/rspec-core-3.0.4/lib/rspec/core/configuration.rb:1025:in `require'
  /Users/Tim/.rvm/gems/ruby-2.3.1@fae/gems/rspec-core-3.0.4/lib/rspec/core/configuration.rb:1025:in `block in requires='
  /Users/Tim/.rvm/gems/ruby-2.3.1@fae/gems/rspec-core-3.0.4/lib/rspec/core/configuration.rb:1025:in `each'
  /Users/Tim/.rvm/gems/ruby-2.3.1@fae/gems/rspec-core-3.0.4/lib/rspec/core/configuration.rb:1025:in `requires='
  /Users/Tim/.rvm/gems/ruby-2.3.1@fae/gems/rspec-core-3.0.4/lib/rspec/core/configuration_options.rb:101:in `block in process_options_into'
  /Users/Tim/.rvm/gems/ruby-2.3.1@fae/gems/rspec-core-3.0.4/lib/rspec/core/configuration_options.rb:100:in `each'
  /Users/Tim/.rvm/gems/ruby-2.3.1@fae/gems/rspec-core-3.0.4/lib/rspec/core/configuration_options.rb:100:in `process_options_into'
  /Users/Tim/.rvm/gems/ruby-2.3.1@fae/gems/rspec-core-3.0.4/lib/rspec/core/configuration_options.rb:22:in `configure'
  /Users/Tim/.rvm/gems/ruby-2.3.1@fae/gems/rspec-core-3.0.4/lib/rspec/core/runner.rb:96:in `setup'
  /Users/Tim/.rvm/gems/ruby-2.3.1@fae/gems/rspec-core-3.0.4/lib/rspec/core/runner.rb:85:in `run'
  /Users/Tim/.rvm/gems/ruby-2.3.1@fae/gems/rspec-core-3.0.4/lib/rspec/core/runner.rb:70:in `run'
  /Users/Tim/.rvm/gems/ruby-2.3.1@fae/gems/rspec-core-3.0.4/lib/rspec/core/runner.rb:38:in `invoke'
  /Users/Tim/.rvm/gems/ruby-2.3.1@fae/gems/rspec-core-3.0.4/exe/rspec:4:in `<top (required)>'
  /Users/Tim/.rvm/gems/ruby-2.3.1@fae/bin/rspec:23:in `load'
  /Users/Tim/.rvm/gems/ruby-2.3.1@fae/bin/rspec:23:in `<top (required)>'

tshedor avatar Jul 25 '16 15:07 tshedor

I'm moving on, but should anyone else pick this up, I've gotten test failures down to 10. I removed Maximus because Brakeman was also using ActionDispatch::ParamsParser, and it's a dependency not worth having.

Main concern is with remotipart because it's a dep we can't remove. Possible solutions: fork it and update the ParamsParser code, submit a PR, or wait for an update.

tshedor avatar Jul 25 '16 16:07 tshedor

Looks like there's already a fork of remotipart that's Rails 5 compatible with a PR on deck: https://github.com/JangoSteve/remotipart/pull/151

jamesmk avatar Jul 25 '16 18:07 jamesmk

Ok - running this rails-5 branch on my personal project. I'll keep a running list of the issues I find. So far:

path: http://localhost:3000/admin/first_user error: couldn't find file 'jquery.ui.sortable' with type 'application/javascript' /Users/nicholebarrett/.rvm/gems/ruby-2.3.1/bundler/gems/fae-810600f83836/app/assets/javascripts/fae/application.js:16

update:

I bundle opened the gem and commented out the following, and it worked.

//  require jquery.ui.sortable
//  require jquery.ui.datepicker

I think it's the version of jquery-ui-rails. Maybe.. http://stackoverflow.com/questions/19171470/ruby-on-rails-couldnt-find-file-jquery-ui-datepicker

LeChin avatar Jul 28 '16 01:07 LeChin

Per Tim's request, I added gem 'jquery-ui-rails', '~> 4.2.1' to my gemfile. This allowed me to deploy successfully.

Now I am getting an error from the credit page. ActionView::Template Error (uninitialized constant Fae::VERSION) on _credit.slim

LeChin avatar Jul 28 '16 18:07 LeChin

Another error:

Steps to recreate

  1. Save a Fae Page with changes a textarea or text field
  2. Error appears:
ActiveRecord::ReadOnlyRecord (Fae::TextArea is marked as readonly):

activerecord (5.0.0) lib/active_record/persistence.rb:533:in `create_or_update'
activerecord (5.0.0) lib/active_record/callbacks.rb:298:in `block in create_or_update'
activesupport (5.0.0) lib/active_support/callbacks.rb:126:in `call'
activesupport (5.0.0) lib/active_support/callbacks.rb:506:in `block (2 levels) in compile'
activesupport (5.0.0) lib/active_support/callbacks.rb:455:in `call'
activesupport (5.0.0) lib/active_support/callbacks.rb:101:in `__run_callbacks__'
activesupport (5.0.0) lib/active_support/callbacks.rb:750:in `_run_save_callbacks'
activerecord (5.0.0) lib/active_record/callbacks.rb:298:in `create_or_update'
activerecord (5.0.0) lib/active_record/persistence.rb:125:in `save'
activerecord (5.0.0) lib/active_record/validations.rb:44:in `save'
activerecord (5.0.0) lib/active_record/attribute_methods/dirty.rb:22:in `save'
activerecord (5.0.0) lib/active_record/transactions.rb:319:in `block (2 levels) in save'
activerecord (5.0.0) lib/active_record/transactions.rb:395:in `block in with_transaction_returning_status'
activerecord (5.0.0) lib/active_record/connection_adapters/abstract/database_statements.rb:230:in `transaction'
activerecord (5.0.0) lib/active_record/transactions.rb:211:in `transaction'
activerecord (5.0.0) lib/active_record/transactions.rb:392:in `with_transaction_returning_status'
activerecord (5.0.0) lib/active_record/transactions.rb:319:in `block in save'
activerecord (5.0.0) lib/active_record/transactions.rb:334:in `rollback_active_record_state!'
activerecord (5.0.0) lib/active_record/transactions.rb:318:in `save'
activerecord (5.0.0) lib/active_record/suppressor.rb:41:in `save'
activerecord (5.0.0) lib/active_record/autosave_association.rb:440:in `save_has_one_association'

Temporary solution:

  1. Make a new concern in models/concerns/fae/text_area_concern.rb:
module Fae::TextAreaConcern
  extend ActiveSupport::Concern

  def readonly?
    false
  end
end
  1. Repeat for Fae::TextFieldConcern.

tshedor avatar Jul 31 '16 21:07 tshedor

@LeChin @jamesmk re: the ActionView::Template Error (uninitialized constant Fae::VERSION) issue - I found a solution and didn't deep dive, although this issue needs to be properly resolved before considering Fae Rails 5-ready.

Set config.eager_load to false in config/environments/production.rb. Like I said, this will have to be revisited because we obviously want eager loading. Maybe requiring the gem for use in views?

tshedor avatar Jul 31 '16 22:07 tshedor

Another thing to note: rails g fae:scaffold doesn't inject properly because it looks for ActiveRecord::Base. Rails 5 models by default inherit from models/application_record.rb, similar to controllers/application_controller.rb. Therefore, the classes look like this: class Guest < ApplicationRecord

In lib/generators/fae/base_generator.rb, the method to inject the Fae concern into the model (inject_concern) relies on ActiveRecord::Base. This cascades to other injections like inject_display_field_to_model.

I resolved this on the rails-5 branch. Additionally, I'm closing this issue out and making a Rails 5 tag to track this issue more effectively.

tshedor avatar Jul 31 '16 23:07 tshedor