railsapps / rails-devise-pundit Goto Github PK
View Code? Open in Web Editor NEWRails 5.0 starter app with Devise for authentication and Pundit for authorization.
Home Page: http://railsapps.github.io/rails-devise-pundit/
Rails 5.0 starter app with Devise for authentication and Pundit for authorization.
Home Page: http://railsapps.github.io/rails-devise-pundit/
I ran the app from composer and additionally installed devise invitable. using ruby 2.1.4 and rails 4.1.7. This composer is amazing and thank you so much. The problem is user names aren't being saved to db. I ran the RailsApp Templates generator for devise and can see in the form params that the name is included with submission. However, it is lost at some point during the email-confirmation process and remains nil
in the database.
I am not sure how to go in and fix this problem. There's a not a User.create(user_params)
like I'm used to so I don't know where the attribute is actually being (unsuccessfully) applied. Editing the user name once logged in does not save either.
I have used the generate commands provided several times:
$ rails new rails-devise-pundit -m https://raw.github.com/RailsApps/rails-composer/master/composer.rb
It works great, except that there is no option to use Pundit for authorization. All I get is this:
question Authorization?
1) None
2) CanCan with Rolify
I can get the application with Pundit from cloning the repo, but then I have to rename the app. This tool would be fantastic if Pundit was part of the composer.
Installing on my Mac, I got "Mysql2::Error: Duplicate column name 'email': ALTER TABLE users
ADD email
"...
I had to remove db/migrations/...AddDeviseToUsers - because it had all the same fields as db/migrations/...DeviseCreateUsers. All good now. Thanks for this whole project!
I'll be looking into this later today, but it seems that you've removed include Pundit from the Application Controller. I noticed this after getting an error on the authorize method.
Am I missing something?
I just followed the instructions and left the secrets.yml as is.
Sign in
user cannot sign in if not registered (FAILED - 1)
user can sign in with valid credentials
user cannot sign in with wrong email (FAILED - 2)
user cannot sign in with wrong password (FAILED - 3)
Sign out
user signs out successfully
User delete
user can delete own account (PENDING: skip a slow test)
User edit
user changes email address
user cannot cannot edit another user's profile
User index page
user sees own email address
User profile page
user sees own profile
user cannot see another user's profile
About page
Visit the about page
Home page
visit the home page
Navigation links
view navigation links
Sign Up
visitor can sign up with valid email address and password
visitor cannot sign up with invalid email address
visitor cannot sign up without password
visitor cannot sign up with a short password (FAILED - 4)
visitor cannot sign up without password confirmation
visitor cannot sign up with mismatched password and confirmation
User
should respond to #email
#email returns a string
UserPolicy
index?
denies access if not an admin
allows access for an admin
show?
prevents other users from seeing your profile
allows you to see your own profile
allows an admin to see any profile
update?
prevents updates if not an admin
allows an admin to make updates
destroy?
prevents deleting yourself
allows an admin to delete any user
Pending: (Failures listed here are expected and do not affect your suite's status)
1) User delete user can delete own account
# skip a slow test
# ./spec/features/users/user_delete_spec.rb:18
Failures:
1) Sign in user cannot sign in if not registered
Failure/Error: expect(page).to have_content I18n.t 'devise.failure.not_found_in_database', authentication_keys: 'email'
expected to find text "Invalid email or password." in "Toggle navigation Home About Sign in Sign up × Invalid Email or password. Sign in Sign up Email Forgot password? Password Remember me". (However, it was found 1 time using a case insensitive search.)
# ./spec/features/users/sign_in_spec.rb:13:in `block (2 levels) in <top (required)>'
2) Sign in user cannot sign in with wrong email
Failure/Error: expect(page).to have_content I18n.t 'devise.failure.not_found_in_database', authentication_keys: 'email'
expected to find text "Invalid email or password." in "Toggle navigation Home About Sign in Sign up × Invalid Email or password. Sign in Sign up Email Forgot password? Password Remember me". (However, it was found 1 time using a case insensitive search.)
# ./spec/features/users/sign_in_spec.rb:35:in `block (2 levels) in <top (required)>'
3) Sign in user cannot sign in with wrong password
Failure/Error: expect(page).to have_content I18n.t 'devise.failure.invalid', authentication_keys: 'email'
expected to find text "Invalid email or password." in "Toggle navigation Home About Sign in Sign up × Invalid Email or password. Sign in Sign up Email Forgot password? Password Remember me". (However, it was found 1 time using a case insensitive search.)
# ./spec/features/users/sign_in_spec.rb:46:in `block (2 levels) in <top (required)>'
4) Sign Up visitor cannot sign up with a short password
Failure/Error: expect(page).to have_content "Password is too short"
expected to find text "Password is too short" in "Toggle navigation Home About Edit account Sign out × Welcome! You have signed up successfully. Welcome Users: 1 registered"
# ./spec/features/visitors/sign_up_spec.rb:41:in `block (2 levels) in <top (required)>'
Finished in 3.63 seconds (files took 5.04 seconds to load)
31 examples, 4 failures, 1 pending
Failed examples:
rspec ./spec/features/users/sign_in_spec.rb:11 # Sign in user cannot sign in if not registered
rspec ./spec/features/users/sign_in_spec.rb:32 # Sign in user cannot sign in with wrong email
rspec ./spec/features/users/sign_in_spec.rb:43 # Sign in user cannot sign in with wrong password
rspec ./spec/features/visitors/sign_up_spec.rb:39 # Sign Up visitor cannot sign up with a short password
I installed railsApps, rails+devise+pundit, after register an user and when list all users, I have this error.
undefined method `authorize' for #<UsersController
def index
@users = User.all
-> authorize User <-
end
before_filter :authenticate_user!
after_action :verify_authorized
def index
@users = User.all
authorize User
end
Just after a fresh generation of rails-devise-pundit, invoking rake assets:precompile on the production environment fails with
TypeError: no implicit conversion of nil into String
Here is the output:
http://pastebin.com/PdyZ3jFM
I've not been able to find any other reports of this happening. Do you have any ideas?
Hi there
looks pretty promising but I am running in some issues:
Even though I have chosen not to create a git repo, the related commands always do run.
BTW:
I got the feeling that since I installed hub and aliased it to git (as recommended) also the rails composer acts different.
The script for the app throws an error during generation and it doesn't seem to work with any combination. The step and resulting error is:
Step:
extras recipe creating project-specific rvm gemset and .rvmrc
Error:
/home/user/.rvm/gems/ruby-2.2.0@global/gems/rvm- 1.11.3.9/lib/rvm/shell/abstract_wrapper.rb:139:in raw_stdout_to_parts': private method
load' called for Psych:Module (NoMethodError)'
The .for method is deprecated in 4.1 +
def configure_permitted_parameters
devise_parameter_sanitizer.for(:sign_up) << :name
devise_parameter_sanitizer.for(:account_update) << :name
end
This should work
def configure_permitted_parameters
devise_parameter_sanitizer.permit(:sign_up, keys: [:name])
devise_parameter_sanitizer.permit(:account_update, keys: [:name])
end
Using Rails 4.1 rc1 and using the generate app method. After building the app, everything works except Sign up. When Sign up is clicked the error uninitialized constant RegistrationsController shows up. Any idea?
Source to App: http://voice-90954.usw1-2.nitrousbox.com/users/sign_up
I tried running the tests and a lot of them failed. Is this expected or is there something wrong with my installation?
Steps to reproduce:
rails new rails-devise-pundit -m https://raw.github.com/RailsApps/rails-composer/master/composer.rb
These are my answers to the interactive wizard (I liberally omitted the parts I think are not important - like the other choices etc)
question Build a starter application?
1) Build a RailsApps example application...
railsapps Enter your selection: 1
question Starter apps for Rails 4.1. More to come.
...
7) rails-devise-pundit
...
railsapps Enter your selection: 7
Get on the mailing list for Rails Composer news?
railsapps Enter your email address: n
recipe Running learn_rails recipe...
setup Your operating system is darwin11.4.2.
setup You are using Ruby version 1.9.3.
setup You are using Rails version 4.1.0.
question Web server for development?
....
3) Unicorn
....
setup Enter your selection: 3
question Web server for production?
3) Unicorn
setup Enter your selection: 3
question Database used in development?
2) PostgreSQL
setup Enter your selection: 2
question Template engine?
2) Haml
setup Enter your selection: 2
question Test framework?
2) RSpec with Capybara
setup Enter your selection: 2
setup Adding DatabaseCleaner, FactoryGirl, Faker, Launchy, Selenium
question Continuous testing?
2) Guard
setup Enter your selection: 2
question Front-end framework?
4) Zurb Foundation 5.0
setup Enter your selection: 4
setup The Devise 'forgot password' feature requires email.
question Add support for sending email?
2) Gmail
setup Enter your selection: 2
question Devise modules?
2) Devise with Confirmable module
setup Enter your selection: 2
question Use a form builder gem?
2) SimpleForm
setup Enter your selection: 2
recipe Running locale recipe...
extras Set a robots.txt file to ban spiders? (y/n) y
extras Create a GitHub repository? (y/n) n
extras Use or create a project-specific rvm gemset? (y/n) n
Your bundle is complete!
Gems in the group production were not installed.
Use `bundle show [gemname]` to see where a bundled gem is installed.
composer Updating gem paths.
WARN: Unresolved specs during Gem::Specification.reset:
json (>= 1.7.7, ~> 1.7)
tzinfo (~> 1.1)
minitest (~> 5.1)
builder (~> 3.1)
rake (>= 0.8.7)
WARN: Clearing out unresolved specs.
Please report a bug if this causes problems.
composer Stage Two (running recipe 'stage_two' callbacks).
composer importing html2haml conversion tool
tests recipe stage two
tests recipe installing RSpec
generate testing:configure rspec -f
run rm -rf test/ from "."
generate rspec:install
create .rspec
create spec
create spec/spec_helper.rb
create spec/rails_helper.rb
insert .rspec
insert .rspec
gsub .rspec
insert config/application.rb
create spec/support/capybara.rb
gsub spec/rails_helper.rb
create spec/support/database_cleaner.rb
create spec/support/factory_girl.rb
tests recipe initializing Guard
run bundle exec guard init from "."
02:32:05 - INFO - Writing new Guardfile to /Users/eumir/Projects/rails-devise-pundit/Guardfile
02:32:05 - INFO - bundler guard added to Guardfile, feel free to edit it
02:32:05 - INFO - rails guard added to Guardfile, feel free to edit it
02:32:05 - INFO - rspec guard added to Guardfile, feel free to edit it
run git add -A from "."
run git commit -qm "rails_apps_composer: testing framework" from "."
email
email recipe stage two
insert config/environments/development.rb
insert config/environments/production.rb
gsub config/environments/production.rb
insert config/environments/development.rb
insert config/environments/production.rb
run git add -A from "."
run git commit -qm "rails_apps_composer: set email accounts" from "."
tests recipe stage three
generate testing:configure devise -f
create spec/support/devise.rb
create spec/support/helpers/session_helpers.rb
create spec/support/helpers.rb
force spec/factories/users.rb
force spec/models/user_spec.rb
create spec/features/users/sign_in_spec.rb
create spec/features/users/sign_out_spec.rb
create spec/features/users/user_delete_spec.rb
create spec/features/users/user_edit_spec.rb
create spec/features/users/user_index_spec.rb
create spec/features/users/user_show_spec.rb
create spec/features/visitors/sign_up_spec.rb
insert spec/factories/users.rb
insert config/environments/test.rb
gsub spec/features/users/user_edit_spec.rb
gsub spec/features/visitors/sign_up_spec.rb
generate testing:configure pundit -f
force spec/factories/users.rb
force spec/features/users/user_index_spec.rb
create spec/policies/user_policy_spec.rb
create spec/support/pundit.rb
Your bundle is complete!
Gems in the group production were not installed.
Use `bundle show [gemname]` to see where a bundled gem is installed.
run bundle exec spring binstub --all
* bin/rake: spring inserted
* bin/rails: spring inserted
After that, I cd
into the directory and run rspec
:
WARNING: Nokogiri was built against LibXML version 2.8.0, but has dynamically loaded 2.9.0
Sign in
. user cannot sign in if not registered
F user can sign in with valid credentials (FAILED - 1)
. user cannot sign in with wrong email
. user cannot sign in with wrong password
Sign out
F user signs out successfully (FAILED - 2)
User delete
* user can delete own account (PENDING: skip a slow test)
User edit
F user changes email address (FAILED - 3)
F user cannot cannot edit another user's profile (FAILED - 4)
User index page
F user sees own email address (FAILED - 5)
User profile page
F user sees own profile (FAILED - 6)
F user cannot see another user's profile (FAILED - 7)
Home page
. visit the home page
Navigation links
. view navigation links
Sign Up
. visitor can sign up with valid email address and password
. visitor cannot sign up with invalid email address
. visitor cannot sign up without password
. visitor cannot sign up with a short password
. visitor cannot sign up without password confirmation
. visitor cannot sign up with mismatched password and confirmation
User
. should respond to #email
. #email returns a string
UserPolicy
index?
. denies access if not an admin
. allows access for an admin
show?
. prevents other users from seeing your profile
. allows you to see your own profile
. allows an admin to see any profile
update?
. prevents updates if not an admin
. allows an admin to make updates
destroy?
. prevents deleting yourself
. allows an admin to delete any user
Pending:
User delete user can delete own account
# skip a slow test
# ./spec/features/users/user_delete_spec.rb:18
Pending:
User delete user can delete own account
# skip a slow test
# ./spec/features/users/user_delete_spec.rb:18
Failures:
1) Sign in user can sign in with valid credentials
Failure/Error: expect(page).to have_content 'Signed in successfully.'
expected to find text "Signed in successfully." in "Home Menu Sign in Sign up You have to confirm your account before continuing. × Sign in Sign up Email Forgot password? Password Remember me"
# ./spec/features/users/sign_in_spec.rb:24:in `block (2 levels) in <top (required)>'
2) Sign out user signs out successfully
Failure/Error: expect(page).to have_content 'Signed in successfully.'
expected to find text "Signed in successfully." in "Home Menu Sign in Sign up You have to confirm your account before continuing. × Sign in Sign up Email Forgot password? Password Remember me"
# ./spec/features/users/sign_out_spec.rb:14:in `block (2 levels) in <top (required)>'
3) User edit user changes email address
Failure/Error: visit edit_user_registration_path(user)
ArgumentError:
uncaught throw :warden
# ./spec/features/users/user_edit_spec.rb:21:in `block (2 levels) in <top (required)>'
4) User edit user cannot cannot edit another user's profile
Failure/Error: visit edit_user_registration_path(other)
ArgumentError:
uncaught throw :warden
# ./spec/features/users/user_edit_spec.rb:36:in `block (2 levels) in <top (required)>'
5) User index page user sees own email address
Failure/Error: visit users_path
ArgumentError:
uncaught throw :warden
# ./spec/features/users/user_index_spec.rb:21:in `block (2 levels) in <top (required)>'
6) User profile page user sees own profile
Failure/Error: visit user_path(user)
ArgumentError:
uncaught throw :warden
# ./spec/features/users/user_show_spec.rb:21:in `block (2 levels) in <top (required)>'
7) User profile page user cannot see another user's profile
Failure/Error: visit user_path(other)
ArgumentError:
uncaught throw :warden
# ./spec/features/users/user_show_spec.rb:35:in `block (2 levels) in <top (required)>'
Failures:
1) Sign in user can sign in with valid credentials
Failure/Error: expect(page).to have_content 'Signed in successfully.'
expected to find text "Signed in successfully." in "Home Menu Sign in Sign up You have to confirm your account before continuing. × Sign in Sign up Email Forgot password? Password Remember me"
# ./spec/features/users/sign_in_spec.rb:24:in `block (2 levels) in <top (required)>'
2) Sign out user signs out successfully
Failure/Error: expect(page).to have_content 'Signed in successfully.'
expected to find text "Signed in successfully." in "Home Menu Sign in Sign up You have to confirm your account before continuing. × Sign in Sign up Email Forgot password? Password Remember me"
# ./spec/features/users/sign_out_spec.rb:14:in `block (2 levels) in <top (required)>'
3) User edit user changes email address
Failure/Error: visit edit_user_registration_path(user)
ArgumentError:
uncaught throw :warden
# ./spec/features/users/user_edit_spec.rb:21:in `block (2 levels) in <top (required)>'
4) User edit user cannot cannot edit another user's profile
Failure/Error: visit edit_user_registration_path(other)
ArgumentError:
uncaught throw :warden
# ./spec/features/users/user_edit_spec.rb:36:in `block (2 levels) in <top (required)>'
5) User index page user sees own email address
Failure/Error: visit users_path
ArgumentError:
uncaught throw :warden
# ./spec/features/users/user_index_spec.rb:21:in `block (2 levels) in <top (required)>'
6) User profile page user sees own profile
Failure/Error: visit user_path(user)
ArgumentError:
uncaught throw :warden
# ./spec/features/users/user_show_spec.rb:21:in `block (2 levels) in <top (required)>'
7) User profile page user cannot see another user's profile
Failure/Error: visit user_path(other)
ArgumentError:
uncaught throw :warden
# ./spec/features/users/user_show_spec.rb:35:in `block (2 levels) in <top (required)>'
Deprecation Warnings:
Filtering by an `:example_group` subhash is deprecated. Use the subhash to filter directly instead. Called from /Users/eumir/.rbenv/versions/1.9.3-p125/lib/ruby/gems/1.9.1/gems/pundit-0.2.3/lib/pundit/rspec.rb:49:in `block in <top (required)>'.
`failure_message_for_should_not` is deprecated. Use `failure_message_when_negated` instead. Called from /Users/eumir/.rbenv/versions/1.9.3-p125/lib/ruby/gems/1.9.1/gems/pundit-0.2.3/lib/pundit/rspec.rb:19:in `block in <module:Matchers>'.
`failure_message_for_should` is deprecated. Use `failure_message` instead. Called from /Users/eumir/.rbenv/versions/1.9.3-p125/lib/ruby/gems/1.9.1/gems/pundit-0.2.3/lib/pundit/rspec.rb:15:in `block in <module:Matchers>'.
`match_for_should_not` is deprecated. Use `match_when_negated` instead. Called from /Users/eumir/.rbenv/versions/1.9.3-p125/lib/ruby/gems/1.9.1/gems/pundit-0.2.3/lib/pundit/rspec.rb:11:in `block in <module:Matchers>'.
`match_for_should` is deprecated. Use `match` instead. Called from /Users/eumir/.rbenv/versions/1.9.3-p125/lib/ruby/gems/1.9.1/gems/pundit-0.2.3/lib/pundit/rspec.rb:7:in `block in <module:Matchers>'.
If you need more of the backtrace for any of these deprecations to
identify where to make the necessary changes, you can configure
`config.raise_errors_for_deprecations!`, and it will turn the
deprecation warnings into errors, giving you the full backtrace.
5 deprecation warnings total
Finished in 23.68 seconds (files took 16.75 seconds to load)
30 examples, 7 failures, 1 pending
Failed examples:
rspec ./spec/features/users/sign_in_spec.rb:21 # Sign in user can sign in with valid credentials
rspec ./spec/features/users/sign_out_spec.rb:11 # Sign out user signs out successfully
rspec ./spec/features/users/user_edit_spec.rb:18 # User edit user changes email address
rspec ./spec/features/users/user_edit_spec.rb:32 # User edit user cannot cannot edit another user's profile
rspec ./spec/features/users/user_index_spec.rb:18 # User index page user sees own email address
rspec ./spec/features/users/user_show_spec.rb:18 # User profile page user sees own profile
rspec ./spec/features/users/user_show_spec.rb:30 # User profile page user cannot see another user's profile
Finished in 23.68 seconds (files took 16.75 seconds to load)
30 examples, 7 failures, 1 pending
Failed examples:
rspec ./spec/features/users/sign_in_spec.rb:21 # Sign in user can sign in with valid credentials
rspec ./spec/features/users/sign_out_spec.rb:11 # Sign out user signs out successfully
rspec ./spec/features/users/user_edit_spec.rb:18 # User edit user changes email address
rspec ./spec/features/users/user_edit_spec.rb:32 # User edit user cannot cannot edit another user's profile
rspec ./spec/features/users/user_index_spec.rb:18 # User index page user sees own email address
rspec ./spec/features/users/user_show_spec.rb:18 # User profile page user sees own profile
rspec ./spec/features/users/user_show_spec.rb:30 # User profile page user cannot see another user's profile
If you encounter an issue like "Sass::SyntaxError at /File to import not found or unreadable: bourbon", simply go to https://rubygems.org/gems/binding_of_caller/ and get binding_of_caller gem. Version 0.72 is the latest as of this writing. You can either include the gem in your "Gemfile" and then run "bundle intall" or simply install the gem using the command line interface. Thanks.
Hi,
I'm getting the error below when trying to setup a new application
I think its related when I select option 4 on the Startup App which is the Admin Dashboard etc
Any ideas?? Error at the bottom
Thanks
Matt
Installation Options
*New App
*Thin
*Thin
*SQLite
*ERB
*None
*Bootstrap 3.0
*None
*Divise
*Devise with default modules
*Pundit
*Simpleform
*Home Page, User Accounts, Admin Dashboard
*n
*n
*n
*n
*n
DL is deprecated, please use Fiddle
rake aborted!
NameError: uninitialized constant Rails3DeviseRspecCucumber
C:/Sites/monasdaa/config/routes.rb:1:in <top (required)>' C:in
execute_if_updated'
C:/Sites/monasdaa/config/environment.rb:5:in <top (required)>' Tasks: TOP => db:migrate => environment (See full trace by running task with --trace) run bundle exec rake db:seed from "." DL is deprecated, please use Fiddle rake aborted! NameError: uninitialized constant Rails3DeviseRspecCucumber C:/Sites/monasdaa/config/routes.rb:1:in
<top (required)>'
C:in execute_if_updated' C:/Sites/monasdaa/config/environment.rb:5:in
<top (required)>'
Tasks: TOP => db:abort_if_pending_migrations => environment
(See full trace by running task with --trace)
run git add -A from "."
run git commit -qm "rails_apps_composer: set up database" from "."
generate layout:devise bootstrap3 -f
DL is deprecated, please use Fiddle
C:/Sites/monasdaa/config/routes.rb:1:in <top (required)>': uninitialized consta nt Rails3DeviseRspecCucumber (NameError) from C:/Ruby200/lib/ruby/gems/2.0.0/gems/railties-4.1.1/lib/rails/applic ation/routes_reloader.rb:40:in
block in load_paths'
from C:/Ruby200/lib/ruby/gems/2.0.0/gems/railties-4.1.1/lib/rails/applic
ation/routes_reloader.rb:40:in each' from C:/Ruby200/lib/ruby/gems/2.0.0/gems/railties-4.1.1/lib/rails/applic ation/routes_reloader.rb:40:in
load_paths'
from C:/Ruby200/lib/ruby/gems/2.0.0/gems/railties-4.1.1/lib/rails/applic
ation/routes_reloader.rb:16:in reload!' from C:/Ruby200/lib/ruby/gems/2.0.0/gems/railties-4.1.1/lib/rails/applic ation/routes_reloader.rb:26:in
block in updater'
from C:/Ruby200/lib/ruby/gems/2.0.0/gems/activesupport-4.1.1/lib/active_
support/file_update_checker.rb:75:in call' from C:/Ruby200/lib/ruby/gems/2.0.0/gems/activesupport-4.1.1/lib/active_ support/file_update_checker.rb:75:in
execute'
from C:/Ruby200/lib/ruby/gems/2.0.0/gems/railties-4.1.1/lib/rails/applic
ation/routes_reloader.rb:27:in updater' from C:in
execute_if_updated'
from C:/Ruby200/lib/ruby/gems/2.0.0/gems/railties-4.1.1/lib/rails/applic
ation/finisher.rb:71:in block in <module:Finisher>' from C:/Ruby200/lib/ruby/gems/2.0.0/gems/railties-4.1.1/lib/rails/initia lizable.rb:30:in
instance_exec'
from C:/Ruby200/lib/ruby/gems/2.0.0/gems/railties-4.1.1/lib/rails/initia
lizable.rb:30:in run' from C:/Ruby200/lib/ruby/gems/2.0.0/gems/railties-4.1.1/lib/rails/initia lizable.rb:55:in
block in run_initializers'
from C:/Ruby200/lib/ruby/2.0.0/tsort.rb:150:in block in tsort_each' from C:/Ruby200/lib/ruby/2.0.0/tsort.rb:183:in
block (2 levels) in each
strongly_connected_component'
from C:/Ruby200/lib/ruby/2.0.0/tsort.rb:219:in each_strongly_connected_ component_from' from C:/Ruby200/lib/ruby/2.0.0/tsort.rb:182:in
block in each_strongly_c
onnected_component'
from C:/Ruby200/lib/ruby/2.0.0/tsort.rb:180:ineach' from C:/Ruby200/lib/ruby/2.0.0/tsort.rb:180:in
each_strongly_connected
component'
from C:/Ruby200/lib/ruby/2.0.0/tsort.rb:148:intsort_each' from C:/Ruby200/lib/ruby/gems/2.0.0/gems/railties-4.1.1/lib/rails/initia lizable.rb:54:in
run_initializers'
from C:/Ruby200/lib/ruby/gems/2.0.0/gems/railties-4.1.1/lib/rails/applic
ation.rb:288:ininitialize!' from C:/Sites/monasdaa/config/environment.rb:5:in
<top (required)>'
from C:/Ruby200/lib/ruby/gems/2.0.0/gems/railties-4.1.1/lib/rails/applic
ation.rb:264:inrequire_environment!' from C:/Ruby200/lib/ruby/gems/2.0.0/gems/railties-4.1.1/lib/rails/comman ds/commands_tasks.rb:147:in
require_application_and_environment!'
from C:/Ruby200/lib/ruby/gems/2.0.0/gems/railties-4.1.1/lib/rails/comman
ds/commands_tasks.rb:133:ingenerate_or_destroy' from C:/Ruby200/lib/ruby/gems/2.0.0/gems/railties-4.1.1/lib/rails/comman ds/commands_tasks.rb:51:in
generate'
from C:/Ruby200/lib/ruby/gems/2.0.0/gems/railties-4.1.1/lib/rails/comman
ds/commands_tasks.rb:40:inrun_command!' from C:/Ruby200/lib/ruby/gems/2.0.0/gems/railties-4.1.1/lib/rails/comman ds.rb:17:in
<top (required)>'
from bin/rails:4:inrequire' from bin/rails:4:in
<top (required)>': uninitialized consta nt Rails3DeviseRspecCucumber (NameError) from C:/Ruby200/lib/ruby/gems/2.0.0/gems/railties-4.1.1/lib/rails/applic ation/routes_reloader.rb:40:in
block in load_paths'each' from C:/Ruby200/lib/ruby/gems/2.0.0/gems/railties-4.1.1/lib/rails/applic ation/routes_reloader.rb:40:in
load_paths'reload!' from C:/Ruby200/lib/ruby/gems/2.0.0/gems/railties-4.1.1/lib/rails/applic ation/routes_reloader.rb:26:in
block in updater'call' from C:/Ruby200/lib/ruby/gems/2.0.0/gems/activesupport-4.1.1/lib/active_ support/file_update_checker.rb:75:in
execute'updater' from C:in
execute_if_updated'block in module:Finisher' from C:/Ruby200/lib/ruby/gems/2.0.0/gems/railties-4.1.1/lib/rails/initia lizable.rb:30:in
instance_exec'run' from C:/Ruby200/lib/ruby/gems/2.0.0/gems/railties-4.1.1/lib/rails/initia lizable.rb:55:in
block in run_initializers'block in tsort_each' from C:/Ruby200/lib/ruby/2.0.0/tsort.rb:183:in
block (2 levels) in eacheach_strongly_connected_ component_from' from C:/Ruby200/lib/ruby/2.0.0/tsort.rb:182:in
block in each_strongly_ceach' from C:/Ruby200/lib/ruby/2.0.0/tsort.rb:180:in
each_strongly_connectedtsort_each' from C:/Ruby200/lib/ruby/gems/2.0.0/gems/railties-4.1.1/lib/rails/initia lizable.rb:54:in
run_initializers'initialize!' from C:/Sites/monasdaa/config/environment.rb:5:in
<top (required)>'require_environment!' from C:/Ruby200/lib/ruby/gems/2.0.0/gems/railties-4.1.1/lib/rails/comman ds/commands_tasks.rb:147:in
require_application_and_environment!'generate_or_destroy' from C:/Ruby200/lib/ruby/gems/2.0.0/gems/railties-4.1.1/lib/rails/comman ds/commands_tasks.rb:51:in
generate'run_command!' from C:/Ruby200/lib/ruby/gems/2.0.0/gems/railties-4.1.1/lib/rails/comman ds.rb:17:in
<top (required)>'require' from bin/rails:4:in
'nothing to commit, working directory clean
extras
extras recipe removing unnecessary files and whitespace
I think you are missing admin name when seeding.
class CreateAdminService
def call
user = User.find_or_create_by!(email: Rails.application.secrets.admin_email) do |user|
user.name= Rails.application.secrets.admin_name
user.password = Rails.application.secrets.admin_password
user.password_confirmation = Rails.application.secrets.admin_password
user.admin!
end
end
end
The factory_girl gem has been renamed to factory_bot as part of this update thoughtbot/factory_bot#921
The generator still tries to locate the factory_girl gem and continues failing the rest of the set-up when the gem is not found.
undefined method `authorize' for #UsersController:0x007f4a55022780
def index
@users = User.all
authorize User
end
Hi,
in the db/seeds.rb file you do a user.confirm!, but the correct variable should be admin.confirm!
# This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
#
# Examples:
#
# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
# Mayor.create(name: 'Emanuel', city: cities.first)
admin = CreateAdminService.new.call
puts 'CREATED ADMIN USER: ' << admin.email
user.confirm!
I created the rails app with the following options:
rails new foobar -m https://raw.github.com/RailsApps/rails-composer/master/composer.rb
recipe Running railsapps recipe...
question Build a starter application?
1) Build a RailsApps example application
2) Build a contributed application
3) I want to build my own application
railsapps Enter your selection: 1
question Starter apps for Rails 4.1. More to come.
1) rails-bootstrap
2) rails-foundation
3) rails-omniauth
4) rails-devise
5) rails-devise-pundit
railsapps Enter your selection: 5
recipe Running setup recipe...
setup Your operating system is darwin13.0.0.
setup You are using Ruby version 2.0.0.
setup You are using Rails version 4.1.0.rc1.
question Web server for development?
1) WEBrick (default)
2) Thin
3) Unicorn
4) Puma
5) Phusion Passenger (Apache/Nginx)
6) Phusion Passenger (Standalone)
setup Enter your selection: 3
question Web server for production?
1) Same as development
2) Thin
3) Unicorn
4) Puma
5) Phusion Passenger (Apache/Nginx)
6) Phusion Passenger (Standalone)
setup Enter your selection: 3
question Database used in development?
1) SQLite
2) PostgreSQL
3) MySQL
4) MongoDB
setup Enter your selection: 1
question Template engine?
1) ERB
2) Haml
3) Slim
setup Enter your selection: 1
question Continuous testing?
1) None
2) Guard
setup Enter your selection: 2
question Front-end framework?
1) None
2) Bootstrap 3.0
3) Bootstrap 2.3
4) Zurb Foundation 5.0
5) Zurb Foundation 4.0
6) Simple CSS
setup Enter your selection: 2
setup The Devise 'forgot password' feature requires email.
question Add support for sending email?
1) None
2) Gmail
3) SMTP
4) SendGrid
5) Mandrill
setup Enter your selection: 4
question Devise modules?
1) Devise with default modules
2) Devise with Confirmable module
3) Devise with Confirmable and Invitable modules
setup Enter your selection: 3
question Use a form builder gem?
1) None
2) SimpleForm
setup Enter your selection: 2
...
extras Set a robots.txt file to ban spiders? (y/n) y
extras Create a GitHub repository? (y/n) n
extras Use or create a project-specific rvm gemset? (y/n) n
....
rake aborted!
undefined local variable or method `user' for main:Object
/Users/adc/Peerialism/hive-portal/db/seeds.rb:10:in `<top (required)>'
/Users/adc/.rvm/gems/ruby-2.0.0-p247/gems/activesupport-4.1.0.rc1/lib/active_support/dependencies.rb:241:in `load'
/Users/adc/.rvm/gems/ruby-2.0.0-p247/gems/activesupport-4.1.0.rc1/lib/active_support/dependencies.rb:241:in `block in load'
/Users/adc/.rvm/gems/ruby-2.0.0-p247/gems/activesupport-4.1.0.rc1/lib/active_support/dependencies.rb:232:in `load_dependency'
/Users/adc/.rvm/gems/ruby-2.0.0-p247/gems/activesupport-4.1.0.rc1/lib/active_support/dependencies.rb:241:in `load'
/Users/adc/.rvm/gems/ruby-2.0.0-p247/gems/railties-4.1.0.rc1/lib/rails/engine.rb:544:in `load_seed'
/Users/adc/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-4.1.0.rc1/lib/active_record/tasks/database_tasks.rb:184:in `load_seed'
/Users/adc/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-4.1.0.rc1/lib/active_record/railties/databases.rake:173:in `block (2 levels) in <top (required)>'
/Users/adc/.rvm/gems/ruby-2.0.0-p247/bin/ruby_executable_hooks:15:in `eval'
/Users/adc/.rvm/gems/ruby-2.0.0-p247/bin/ruby_executable_hooks:15:in `<main>'
Tasks: TOP => db:seed
...
I have no idea why this isn't working. I've followed every single possible tutorial on setting the environmental variables.
I've set it this way
heroku config:add SECRET_KEY_BASE="keystuff" --remote production --app appname
2014-03-15T02:52:26.326250+00:00 app[web.1]: Unexpected error while processing request: Missing `secret_key_base` for 'production' environment, set this value in `config/secrets.yml`
And I keep getting the same error. I've tried every tutorial and article. What could I be doing wrong?!
init applying migrations and seeding the database
run bundle exec rake db:migrate from "."
run bundle exec rake db:seed from "."
ROLES
rake aborted!
ActiveRecord::StatementInvalid: PG::UndefinedTable: ERROR: relation "roles" does not exist
LINE 5: WHERE a.attrelid = '"roles"'::regclass
^
: SELECT a.attname, format_type(a.atttypid, a.atttypmod),
pg_get_expr(d.adbin, d.adrelid), a.attnotnull, a.atttypid, a.atttypmod
FROM pg_attribute a LEFT JOIN pg_attrdef d
ON a.attrelid = d.adrelid AND a.attnum = d.adnum
WHERE a.attrelid = '"roles"'::regclass
AND a.attnum > 0 AND NOT a.attisdropped
ORDER BY a.attnum
/Users/stereodenis/work/stereopark/rails-devise-pundit/db/seeds.rb:12:in 'block in <top (required)>'
/Users/stereodenis/work/stereopark/rails-devise-pundit/db/seeds.rb:11:in 'each'
/Users/stereodenis/work/stereopark/rails-devise-pundit/db/seeds.rb:11:in '<top (required)>'
Tasks: TOP => db:seed
(See full trace by running task with --trace)
I have been fighting with this for hours and I cannot get the app to pre-compile. It works great on my local environment, but I am trying to push it up to Heroku, but everytime I run 'RAILS_ENV=production rake assets:precompile' I get the below error. Any help would be great. Thank you.
' charles@rooster:~/apps/cfi-app$ RAILS_ENV=production rake assets:precompile
rake aborted!
TypeError: no implicit conversion of nil into String
/home/charles/apps/cfi-app/config/initializers/devise.rb:13:in +' /home/charles/apps/cfi-app/config/initializers/devise.rb:13:in
block in <top (required)>'
/home/charles/.rvm/gems/ruby-2.1.0@cfi-app/gems/devise-3.2.4/lib/devise.rb:288:in setup' /home/charles/apps/cfi-app/config/initializers/devise.rb:3:in
<top (required)>'
/home/charles/.rvm/gems/ruby-2.1.0@cfi-app/gems/activesupport-4.1.4/lib/active_support/dependencies.rb:241:in load' /home/charles/.rvm/gems/ruby-2.1.0@cfi-app/gems/activesupport-4.1.4/lib/active_support/dependencies.rb:241:in
block in load'
/home/charles/.rvm/gems/ruby-2.1.0@cfi-app/gems/activesupport-4.1.4/lib/active_support/dependencies.rb:232:in load_dependency' /home/charles/.rvm/gems/ruby-2.1.0@cfi-app/gems/activesupport-4.1.4/lib/active_support/dependencies.rb:241:in
load'
/home/charles/.rvm/gems/ruby-2.1.0@cfi-app/gems/railties-4.1.4/lib/rails/engine.rb:648:in block in load_config_initializer' /home/charles/.rvm/gems/ruby-2.1.0@cfi-app/gems/activesupport-4.1.4/lib/active_support/notifications.rb:161:in
instrument'
/home/charles/.rvm/gems/ruby-2.1.0@cfi-app/gems/railties-4.1.4/lib/rails/engine.rb:647:in load_config_initializer' /home/charles/.rvm/gems/ruby-2.1.0@cfi-app/gems/railties-4.1.4/lib/rails/engine.rb:612:in
block (2 levels) in class:Engine'
/home/charles/.rvm/gems/ruby-2.1.0@cfi-app/gems/railties-4.1.4/lib/rails/engine.rb:611:in each' /home/charles/.rvm/gems/ruby-2.1.0@cfi-app/gems/railties-4.1.4/lib/rails/engine.rb:611:in
block in class:Engine'
/home/charles/.rvm/gems/ruby-2.1.0@cfi-app/gems/railties-4.1.4/lib/rails/initializable.rb:30:in instance_exec' /home/charles/.rvm/gems/ruby-2.1.0@cfi-app/gems/railties-4.1.4/lib/rails/initializable.rb:30:in
run'
/home/charles/.rvm/gems/ruby-2.1.0@cfi-app/gems/railties-4.1.4/lib/rails/initializable.rb:55:in block in run_initializers' /home/charles/.rvm/gems/ruby-2.1.0@cfi-app/gems/railties-4.1.4/lib/rails/initializable.rb:44:in
each'
/home/charles/.rvm/gems/ruby-2.1.0@cfi-app/gems/railties-4.1.4/lib/rails/initializable.rb:44:in tsort_each_child' /home/charles/.rvm/gems/ruby-2.1.0@cfi-app/gems/railties-4.1.4/lib/rails/initializable.rb:54:in
run_initializers'
/home/charles/.rvm/gems/ruby-2.1.0@cfi-app/gems/railties-4.1.4/lib/rails/application.rb:300:in initialize!' /home/charles/apps/cfi-app/config/environment.rb:5:in
<top (required)>'
/home/charles/.rvm/gems/ruby-2.1.0@cfi-app/gems/activesupport-4.1.4/lib/active_support/dependencies.rb:247:in require' /home/charles/.rvm/gems/ruby-2.1.0@cfi-app/gems/activesupport-4.1.4/lib/active_support/dependencies.rb:247:in
block in require'
/home/charles/.rvm/gems/ruby-2.1.0@cfi-app/gems/activesupport-4.1.4/lib/active_support/dependencies.rb:232:in load_dependency' /home/charles/.rvm/gems/ruby-2.1.0@cfi-app/gems/activesupport-4.1.4/lib/active_support/dependencies.rb:247:in
require'
/home/charles/.rvm/gems/ruby-2.1.0@cfi-app/gems/railties-4.1.4/lib/rails/application.rb:276:in require_environment!' /home/charles/.rvm/gems/ruby-2.1.0@cfi-app/gems/railties-4.1.4/lib/rails/application.rb:379:in
block in run_tasks_blocks'
/home/charles/.rvm/gems/ruby-2.1.0@cfi-app/gems/sprockets-rails-2.1.3/lib/sprockets/rails/task.rb:55:in block (2 levels) in define' /home/charles/.rvm/gems/ruby-2.1.0@cfi-app/bin/ruby_executable_hooks:15:in
eval'
/home/charles/.rvm/gems/ruby-2.1.0@cfi-app/bin/ruby_executable_hooks:15:in `
Forgive me, I'm only a few months into RoR, but I can't seem to figure this out.
I have chosen the rails-devise-pundit app to start to build from and I keep getting the above mentioned error :
"Net::SMTPAuthenticationError at /users
530-5.5.1 Authentication Required." with a lot of blocks included
When I chose the other options in rails composer i always get errors thrown after trying to sign up. The only time it ever went through the sign up is when i chose 'no email provider' to be used in the composer, so I'm assuming there are issues with configuring the mail...?
I've tried hardcoding both in the development.rb, production.rb, and secrets.yml. I followed tne "Send Emails..." article too.
Any clue what's wrong, or what it is that I'm doing wrong?
Hi,
When using the Rails Composer option, it creates a rails 4.0.2 app without the config/secrets.yml file which makes some of the generators to fail.
There's a mismatch between cloning and using the composer and hence it's a bit confusing as the tutorial doesn't describe the flow when cloning (it lacks many of the composer options...)
Thanks,
Roy
I saw in the user policy example you have, you use:
class UserPolicy
attr_reader :current_user, :model
def initialize(current_user, model)
@current_user = current_user
@user = model
end
def index?
@current_user.admin?
end
I thought the point of attr_reader was to set access to the local variable. If that's the case, why do you use '@' in the action methods? Shouldn't your notation be 'current_user.admin? in the action methods?
I'm trying to learn how to write scopes and getting very stuck with the examples I can find to this point. I think my struggles have something to do with the notation. I'd love to know why you use this format. It might help me understand what's going wrong for me.
Hello,
In my application user can have multiple roles, I want to provide an option to change his role, based on his current role I want to enable/disable features for that user. So how I can do this?
Please suggest me on this.
Thanks
The script generates errors when trying to access MySQL.
At the step:
Okay to drop all existing databases named rails-devise-pundit? 'No' will abort immediately! (y/n) y
run bundle exec rake db:drop from "."
[Simple Form] Simple Form is not configured in the application and will use the default values. Use rails generate simple_form:install
to generate the Simple Form configuration.
rake aborted!
Mysql2::Error: Access denied for user 'rails-devise-pundit'@'localhost' (using password: NO)
/home/benny/.rbenv/versions/2.3.1/bin/bundle:22:in load' /home/benny/.rbenv/versions/2.3.1/bin/bundle:22:in
Mysql2::Error: No database selected: GRANT ALL PRIVILEGES ON rails-devise-pundit_development.* TO 'rails-devise-pundit'@'localhost' IDENTIFIED BY '' WITH GRANT OPTION;
Couldn't create database for {"adapter"=>"mysql2", "encoding"=>"utf8", "reconnect"=>false, "database"=>"rails-devise-pundit_development", "pool"=>5, "username"=>"rails-devise-pundit", "password"=>nil, "host"=>"localhost"}
rake aborted!
ActiveRecord::StatementInvalid: Mysql2::Error: No database selected: GRANT ALL PRIVILEGES ON rails-devise-pundit_development.* TO 'rails-devise-pundit'@'localhost' IDENTIFIED BY '' WITH GRANT OPTION;
/home/benny/.rbenv/versions/2.3.1/bin/bundle:22:in load' /home/benny/.rbenv/versions/2.3.1/bin/bundle:22:in
load' /home/benny/.rbenv/versions/2.3.1/bin/bundle:22:in
'load' /home/benny/.rbenv/versions/2.3.1/bin/bundle:22:in
'All subsequent commands to the database fail as well.
For the omni-auth installation, dotenv-rails is not added to the gemfile. Since you're referencing env variables in the secrets.yml file, dotenv-rails would be helpful to add to the gemfile as well upon setup. Thanks!
I generated a rails-devise-pundit app with the ff setup:
looking at the files here and here, it seems that they differ greatly.
Here is a screenshot of the ERB at work:
and here is the screenshot of the HAML file at work:
As you can see, styles are broken. Also, notice the additional links below (the devise links). Lastly, I had to delete the ERB file for the HAML file to render (and have to always restart the rails server - which seems suspicious)
Any thoughts?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.