Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

can't install on rails 5.1 #76

Open
giovapanasiti opened this issue Jul 11, 2017 · 17 comments
Open

can't install on rails 5.1 #76

giovapanasiti opened this issue Jul 11, 2017 · 17 comments

Comments

@giovapanasiti
Copy link

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)
@jekuno
Copy link
Owner

jekuno commented Jul 11, 2017

Can you add some information about your insights for other users finding this issue?

@giovapanasiti giovapanasiti reopened this Jul 11, 2017
@giovapanasiti
Copy link
Author

giovapanasiti commented Jul 11, 2017

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

@8geonirt
Copy link

@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

@giovapanasiti
Copy link
Author

@8geonirt I did it

@jekuno
Copy link
Owner

jekuno commented Jul 23, 2017

What exactly are you doing in order to create a user with a tenant?

@8geonirt
Copy link

8geonirt commented Jul 24, 2017

@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.

@jekuno
Copy link
Owner

jekuno commented Jul 26, 2017

@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.

@aaronjensen
Copy link

fwiw, that branch fixed things on rails 5.1 for me. It'd be great if that and 4c36b46 were released so it works out of the box w/ 5.1. Thanks!

@alfredodfn
Copy link

@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='no-reply@minhalista.com.br' --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>'

@ajithkgatty
Copy link

ajithkgatty commented Nov 6, 2017

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

@khushdeepgoku
Copy link

adding this before_action :authenticate_tenant! manually in application_controller should do the work.
And then run rails g milia:install --org_email=''.

@feiting8977
Copy link

feiting8977 commented Jun 20, 2018

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

@mmaberry-yottaa
Copy link

mmaberry-yottaa commented Jul 4, 2018

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='do-not-reply@local-test.dev'

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='do-not-reply@local-test.dev' 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.

@hermanomark
Copy link

@mmaberry-yottaa thanks!

But I would like to add, when running rails g milia:install --org_email='do-not-reply@local-test.dev' 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.

@melferium
Copy link

@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

@sulimanalkous
Copy link

Thank you @ajithkgatty

@dineshshekhawat
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests