Redirect to log in page if user is not authenticated with Devise

Just simple add this method to application_controller.rb protected def authenticate_user! if user_signed_in? super else redirect_to login_path, :notice => ‘if you want to add a notice’ ## if you want render 404 page ## render :file => File.join(Rails.root, ‘public/404’), :formats => [:html], :status => 404, :layout => false end end And you can call this method … Read more

Is the ‘Travel’ time helper not available in feature specs?

In order to use these helpers you have to include them into your tests. You can do this by either including it into single test suite: describe MyClass do include ActiveSupport::Testing::TimeHelpers end or globally: RSpec.configure do |config| config.include ActiveSupport::Testing::TimeHelpers end

Rails migration does not change schema.rb

From the documentation: The rake db:reset task will drop the database, recreate it and load the current schema into it. This is not the same as running all the migrations. It will only use the contents of the current schema.rb file. If a migration can’t be rolled back, ‘rake db:reset’ may not help you. To … Read more

tech