How to validate text isn’t blank in Rails

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

rails:3 Devise signup Filter chain halted as :require_no_authentication rendered or redirected

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

Using factory_girl_rails with Rspec on namespaced models

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

Rails routing – :on => :collection

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