How would I clear all rails sessions?
Whether it’s DB or cookie store, use rake tmp:sessions:clear
Whether it’s DB or cookie store, use rake tmp:sessions:clear
Try this <%= form.select “availability”, options_for_select(1..200), {}, {required: ‘true’, autofocus: ‘true’, class: ‘form-control’} %> Possible options for third argument are :prompt and :include_blank
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
Here’s one way: class String def valid_float? # The double negation turns this into an actual boolean true – if you’re # okay with “truthy” values (like 0.0), you can remove it. !!Float(self) rescue false end end “a”.valid_float? #false “2.4”.valid_float? #true If you want to avoid the monkey-patch of String, you could always make this … Read more
I had the same problem, and although I did not solve the problem, I found a workaround. Instead of using: heroku run rake db:migrate You can use: heroku run:detached rake db:migrate This runs the command in the background, writing the output to the log. When it is finished you can view the log for the … Read more
You can do array differences, if the result is the empty array, the 2 arrays contained the same elements: >> [1,2,3]-[3,1,2] #=> [] If you still have elements left, then not all elements of the first array were present in the second one: >> [1,2,5]-[3,1,2] #=> [5]
I have already fixed it. The solution was to change gem ‘factory_girl’ to gem ‘factory_girl_rails’ in my Gemfile.
Try this it worked for me: RAILS_ENV=production rake db:drop DISABLE_DATABASE_ENVIRONMENT_CHECK=1 in a single line.
It’s simple to spend the three minutes (maybe two if you type fast) to add a swap file to your server. If you’re running Ubuntu (not sure how well this works for other Linux flavors), just follow this tutorial from DigitalOcean: https://www.digitalocean.com/community/articles/how-to-add-swap-on-ubuntu-12-04 Voila!
You could use except: params.except(:action, :controller) http://as.rubyonrails.org/classes/ActiveSupport/CoreExtensions/Hash/Except.html