Testing (RSpec) with Devise’s confirmable module

In your test environment ActionMailer::Base.delivery_method should be set to :test, which means that these emails will not be sent out. If this setting is set to something else such as smtp by way of a configuration in say config/environments.rb, then emails will be sent out. If that setting’s already there, then to use the User … Read more

Why do I get a bcrypt-ruby gem install error?

I had the same problem installing under OSX 10.7.3. When installing the gem, my error message was: Building native extensions. This could take a while… ERROR: Error installing bcrypt-ruby: ERROR: Failed to build gem native extension. creating Makefile make compiling bcrypt_ext.c make: /usr/bin/gcc-4.2: No such file or directory make: *** [bcrypt_ext.o] Error 1 Looks like … Read more

Rails before_filter for specific actions in controller

Create in your ApplicationController method: def check_privileges! redirect_to “https://stackoverflow.com/”, notice: ‘You dont have enough permissions to be here’ unless current_admin || current_company end And then in your controller: before_filter :check_privileges!, only: [:new, :create, :edit, :save] Or before_filter :check_privileges!, except: [:index, :show]

How to create the first (Admin) user (CanCan and Devise)?

You can do it from the rails console. From the command line goto the directory of your rails application and type rails console. Then enter the following code to create a user: user=User.create!(:email=>'[email protected]’,:username=>’test’,:password=>’password’) This will create a user object (assuming your devise resource is called User). Now you can use the user object that you … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)