milia
milia copied to clipboard
can't install on rails 5.1
this is the error i get:
.rvm/gems/ruby-2.3.0/gems/activesupport-5.1.2/lib/active_support/callbacks.rb:710:in `block (2 levels) in skip_callback': Before process_action callback :authenticate_tenant! has not been defined (ArgumentError)
Can you add some information about your insights for other users finding this issue?
Sorry I closed it by mistake at the end I'm still fighting I solve a couple of errors and got everything installed but not working.
What I did was first install and configure devise by itself then add milia and run the installer skipping devise configuration and I had to change in DevisePermittedParameters
:
before_filter
in before_action
and added before_action :authenticate_tenant!
manually in application_controller
But still isn't working infact when I try to create a user with a tenant it says: Tenants must exists
@giovapanasiti Hi! I'm pretty sure you haven't created the necessary migrations
Setup base models
Necessary models: User, Tenant
Necessary migrations: user, tenant, tenants_users (join table)
Generate the tenant migration
$ rails g model tenant tenant:references name:string:index
Generate the tenants_users join table migration
$ rails g migration CreateTenantsUsersJoinTable tenants users
Here's the readme https://github.com/jekuno/milia#setup-base-models
@8geonirt I did it
What exactly are you doing in order to create a user with a tenant?
@jekuno @giovapanasiti I figured out what is going on, the Tenants must exists
error is happening because on newer versions of Rails (5.x) there is a restriction on the belongs_to
instruction, for more info look at this code: https://github.com/rails/rails/blob/58f10a31b37e9bb6e975a71aa63744f318ee043d/railties/lib/rails/application/configuration.rb#L68
If we remove the config.load_defaults 5.1
from the config/application.rb
file then the Tenant
creation will work, but I think that's not recommended because we're turning off some Rails 5 features.
@8geonirt Thanks for investigating it. Would you be so kind to test whether switching to branch issue#76 (https://github.com/jekuno/milia/tree/issue%2376) fixes your issue?
Add to your Gemfile gem 'milia', github: 'jekuno/milia', branch: 'issue#76'
and run bundle install
.
fwiw, that branch fixed things on rails 5.1 for me. It'd be great if that and 4c36b46f3f422b22fa48a98abd646e562667ed83 were released so it works out of the box w/ 5.1. Thanks!
@jekuno I get the same error for rails 5.1.14 and ruby ruby 2.4.0p0 using "gem 'milia', github: 'jekuno/milia', branch: 'issue#76'". Output:
rails g milia:install --org_email='[email protected]' --skip_devise_generators=true
/home/ubuntu/workspace/minha-lista/config/initializers/devise_permitted_parameters.rb:5:in `block in <module:DevisePermittedParameters>': undefined method `before_filter' for DeviseController:Class
Did you mean? before_action (NoMethodError)
from /usr/local/rvm/gems/ruby-2.4.0@minha-lista/gems/activesupport-5.1.4/lib/active_support/concern.rb:120:in `class_eval'
from /usr/local/rvm/gems/ruby-2.4.0@minha-lista/gems/activesupport-5.1.4/lib/active_support/concern.rb:120:in `append_features'
from /home/ubuntu/workspace/minha-lista/config/initializers/devise_permitted_parameters.rb:18:in `include'
from /home/ubuntu/workspace/minha-lista/config/initializers/devise_permitted_parameters.rb:18:in `<top (required)>'
from /usr/local/rvm/gems/ruby-2.4.0@minha-lista/gems/activesupport-5.1.4/lib/active_support/dependencies.rb:286:in `load'
from /usr/local/rvm/gems/ruby-2.4.0@minha-lista/gems/activesupport-5.1.4/lib/active_support/dependencies.rb:286:in `block in load'
from /usr/local/rvm/gems/ruby-2.4.0@minha-lista/gems/activesupport-5.1.4/lib/active_support/dependencies.rb:258:in `load_dependency'
from /usr/local/rvm/gems/ruby-2.4.0@minha-lista/gems/activesupport-5.1.4/lib/active_support/dependencies.rb:286:in `load'
from /usr/local/rvm/gems/ruby-2.4.0@minha-lista/gems/railties-5.1.4/lib/rails/engine.rb:655:in `block in load_config_initializer'
from /usr/local/rvm/gems/ruby-2.4.0@minha-lista/gems/activesupport-5.1.4/lib/active_support/notifications.rb:168:in `instrument'
from /usr/local/rvm/gems/ruby-2.4.0@minha-lista/gems/railties-5.1.4/lib/rails/engine.rb:654:in `load_config_initializer'
from /usr/local/rvm/gems/ruby-2.4.0@minha-lista/gems/railties-5.1.4/lib/rails/engine.rb:612:in `block (2 levels) in <class:Engine>'
from /usr/local/rvm/gems/ruby-2.4.0@minha-lista/gems/railties-5.1.4/lib/rails/engine.rb:611:in `each'
from /usr/local/rvm/gems/ruby-2.4.0@minha-lista/gems/railties-5.1.4/lib/rails/engine.rb:611:in `block in <class:Engine>'
from /usr/local/rvm/gems/ruby-2.4.0@minha-lista/gems/railties-5.1.4/lib/rails/initializable.rb:30:in `instance_exec'
from /usr/local/rvm/gems/ruby-2.4.0@minha-lista/gems/railties-5.1.4/lib/rails/initializable.rb:30:in `run'
from /usr/local/rvm/gems/ruby-2.4.0@minha-lista/gems/railties-5.1.4/lib/rails/initializable.rb:59:in `block in run_initializers'
from /usr/local/rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/tsort.rb:228:in `block in tsort_each'
from /usr/local/rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component'
from /usr/local/rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/tsort.rb:422:in `block (2 levels) in each_strongly_connected_component_from'
from /usr/local/rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/tsort.rb:431:in `each_strongly_connected_component_from'
from /usr/local/rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/tsort.rb:421:in `block in each_strongly_connected_component_from'
from /usr/local/rvm/gems/ruby-2.4.0@minha-lista/gems/railties-5.1.4/lib/rails/initializable.rb:48:in `each'
from /usr/local/rvm/gems/ruby-2.4.0@minha-lista/gems/railties-5.1.4/lib/rails/initializable.rb:48:in `tsort_each_child'
from /usr/local/rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/tsort.rb:415:in `call'
from /usr/local/rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/tsort.rb:415:in `each_strongly_connected_component_from'
from /usr/local/rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/tsort.rb:349:in `block in each_strongly_connected_component'
from /usr/local/rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/tsort.rb:347:in `each'
from /usr/local/rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/tsort.rb:347:in `call'
from /usr/local/rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/tsort.rb:347:in `each_strongly_connected_component'
from /usr/local/rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/tsort.rb:226:in `tsort_each'
from /usr/local/rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/tsort.rb:205:in `tsort_each'
from /usr/local/rvm/gems/ruby-2.4.0@minha-lista/gems/railties-5.1.4/lib/rails/initializable.rb:58:in `run_initializers'
from /usr/local/rvm/gems/ruby-2.4.0@minha-lista/gems/railties-5.1.4/lib/rails/application.rb:353:in `initialize!'
from /home/ubuntu/workspace/minha-lista/config/environment.rb:5:in `<top (required)>'
from /usr/local/rvm/gems/ruby-2.4.0@minha-lista/gems/activesupport-5.1.4/lib/active_support/dependencies.rb:292:in `require'
from /usr/local/rvm/gems/ruby-2.4.0@minha-lista/gems/activesupport-5.1.4/lib/active_support/dependencies.rb:292:in `block in require'
from /usr/local/rvm/gems/ruby-2.4.0@minha-lista/gems/activesupport-5.1.4/lib/active_support/dependencies.rb:258:in `load_dependency'
from /usr/local/rvm/gems/ruby-2.4.0@minha-lista/gems/activesupport-5.1.4/lib/active_support/dependencies.rb:292:in `require'
from /usr/local/rvm/gems/ruby-2.4.0@minha-lista/gems/spring-2.0.2/lib/spring/application.rb:102:in `preload'
from /usr/local/rvm/gems/ruby-2.4.0@minha-lista/gems/spring-2.0.2/lib/spring/application.rb:153:in `serve'
from /usr/local/rvm/gems/ruby-2.4.0@minha-lista/gems/spring-2.0.2/lib/spring/application.rb:141:in `block in run'
from /usr/local/rvm/gems/ruby-2.4.0@minha-lista/gems/spring-2.0.2/lib/spring/application.rb:135:in `loop'
from /usr/local/rvm/gems/ruby-2.4.0@minha-lista/gems/spring-2.0.2/lib/spring/application.rb:135:in `run'
from /usr/local/rvm/gems/ruby-2.4.0@minha-lista/gems/spring-2.0.2/lib/spring/application/boot.rb:19:in `<top (required)>'
from /usr/local/rvm/rubies/ruby-b
from /usr/local/rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from -e:1:in `<main>'
project details -> rails 5.1.4 and ruby 2.4.1 i had to explicitly go into the device_permitted_parameter.rb and replace the included block to below one.
included do
before_action :configure_permitted_parameters
end
Thanks -Ajith
adding this before_action :authenticate_tenant! manually in application_controller should do the work.
And then run rails g milia:install --org_email='
i added the before_action :authenticate_tenant! in the application_controller, then run rails g milia:install. still have the error. also i changed the gemfile to gem 'milia', github: 'jekuno/milia', branch: 'issue#76'. still nothing changed
Environment: ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-linux] Rails 5.2.0
Gem: gem 'devise' gem 'milia', github: 'jekuno/milia', branch: 'issue#76'
Application Controller: `class ApplicationController < ActionController::Base before_action :authenticate_tenant! # authenticate user and sets up tenant
end`
Command: rails g milia:install --org_email='[email protected]'
Error:
/home/ec2-user/environment/saas-project-app/config/initializers/devise_permitted_parameters.rb:5:in
block in module:DevisePermittedParameters': undefined method before_filter' for DeviseController:Class Did you mean? before_action (NoMethodError)
Things I tried: followed @ajithkgatty suggestion of updating /config/initializers/devise_permitted_parameters.rb. When I ran rails g milia:install --org_email='[email protected]' I got a notice of a conflict and chose Y to overwrite and it appears that milia/devise has properly installed.
`Running via Spring preloader in process 9291 conflict config/initializers/devise_permitted_parameters.rb Overwrite /home/ec2-user/environment/saas-project-app/config/initializers/devise_permitted_parameters.rb? (enter "h" for help) [Ynaqdh] Y force config/initializers/devise_permitted_parameters.rb identical config/initializers/milia.rb gemfile activerecord-session_store run bundle install ... bunch of stuff ...
milia installation complete please edit your email, domain, password in config/environments/* please edit devise config/initializers/devise.rb please run migrations: $ rake db:migrate
`
Hope this helps someone else.
@mmaberry-yottaa thanks!
But I would like to add, when running rails g milia:install --org_email='[email protected]' again, don't type Y when it ask you to overwrite devise_permitted_paramters.rb type N instead, to not overwrite the before_action you've edited.
@mmaberry-yottaa, thanks! it works on my case. I am using: WSL Ubuntu 18.04.1 LTS ruby 2.5.3p105 (2018-10-18 revision 65156) [x86_64-linux] Rails 5.2.1
Thank you @ajithkgatty
adding this before_action :authenticate_tenant! manually in application_controller should do the work. And then run rails g milia:install --org_email=''.
This worked for me