Rails 5 how to clear or delete production postgres database
Try this it worked for me: RAILS_ENV=production rake db:drop DISABLE_DATABASE_ENVIRONMENT_CHECK=1 in a single line.
Try this it worked for me: RAILS_ENV=production rake db:drop DISABLE_DATABASE_ENVIRONMENT_CHECK=1 in a single line.
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
As indicated in Devise documentation notes for Rails 5 For Rails 5, note that protect_from_forgery is no longer prepended to the before_action chain, so if you have set authenticate_user before protect_from_forgery, your request will result in “Can’t verify CSRF token authenticity.” To resolve this, either change the order in which you call them, or use … Read more
Using JQuery Server side datatables in ruby app and pagination shows blank page after 1st page
Two Fixes to ActiveRecord::NoEnvironmentInSchemaError The other answers here describe the problem very well, but lack proper solutions. Hoping this answer helps someone experiencing this issue. Why this error is happening This incorrect error message is a result of this pull request designed to prevent destructive actions on production databases. As u/pixelearth correctly points out, Rails … Read more
Check if your ApplicationController has a call to protect_from_forgery as follows: class ApplicationController < ActionController::Base protect_from_forgery with: :exception end Essentially calling protect_from_forgery adds verify_authenticity_token to the before_filter list, which you can skip in the other controllers. Refer to protect_from_forgery documentation for more info.
For me it was resolved in this way: Select advisory locks: SELECT pid, locktype, mode FROM pg_locks WHERE locktype=”advisory”; SELECT pg_terminate_backend(<PID>);
For my User which has_one_attached :avatar I can get the url in my views with <%= image_tag url_for(user.avatar) %>. So, in controller I would use just url_for(user.avatar) For Category which has_one_attached :image: url_for(category.image)
You can use a lambda for the if: clause and do an or condition. validates :description, presence: true, if: -> {current_step == steps.first || require_validation}
I found the answer in RubyGems issue #1551 here. The binstubs, the files in the bin folder, need to be updated. The best way to do this is: bundle update spring bundle exec spring binstub –remove –all bundle exec spring binstub –all And that resolved the problem for me.