Saving a HASH to Redis on a rails app
I should have read the redis docs more thorough. Answer: IN $redis.set ‘data’, hash.to_json OUT data = JSON.parse($redis.get(“data”))
I should have read the redis docs more thorough. Answer: IN $redis.set ‘data’, hash.to_json OUT data = JSON.parse($redis.get(“data”))
git remote add heroku git@heroku.com:your_app_name.git
Rails adds the handy method blank? which checks for false, nil and empty strings as described here. Rails also adds the handy validator allow_blank: false. So in your case it should be: validates :body, presence: true, allow_blank: false Edit (original answer above): As stated in the answer below, allow_blank: false is not needed as that’s … Read more
The mentioned line on Devise’s Controller makes sense in general cases: a logged in user can’t sign up. As you’re on a case where only an admin can create a user, I would suggest that you don’t use Devise’s controller on Registerable module and write your own controller with your own rules. You can write … Read more
I have a minimal working example here, maybe you could use it to pinpoint where your problem is. The comment you left on dmarkow’s answer suggests to me that you have an error someplace else. app/models/bar/foo.rb class Bar::Foo < ActiveRecord::Base end *db/migrate/20110614204536_foo.rb* class Foo < ActiveRecord::Migration def self.up create_table :foos do |t| t.string :name end … Read more
Routes on collections are listed here. The difference between :on => :collection and :on => :member are the style of route they produce and their associated route helpers. resources :posts do # on collection get ‘search’, on: :collection # –> generates ‘/posts/search’ and search_posts_path # on member get ‘share’, on: :member # –> generates’/posts/:id/share’ and … Read more
Get the user out of the database: user = User.find_by_email(params[:email]) Then you can check their password with: user.valid_password?(params[:password])
I had a problem like this before. It was caused after I had precompiled the assets it was going after the applcation.css inside the public folder as well as in the apps directory. I’m not sure how to fix it so that it doesn’t keep happening while in dev mode but if you delete your … Read more
The other answer works but leaves a ? at the end in case there are no parameters. This seems to do the trick without the side effects: root to: redirect(path: ‘/quick_searches/new’) Hope it helps!
With this… WebMock.disable_net_connect!(:allow_localhost => true) you allow real web access to your localhost. It’s perfect when you need to use Selenium for you application and, at the same time, mock external resources.