Heroku upload-Precompiling assets failed

From the Heroku docs: This means that your app is attempting to connect to the database as part of rake assets:precompile. Because the config vars are not present in the environment, we use a placeholder DATABASE_URL to satisfy Rails. To resolve this issue, ensure that the following line appears in your config/application.rb: # config/application.rb config.assets.initialize_on_precompile … Read more

rails built in datetime validation

There’s no built-in ActiveRecord validator for DateTimes, but you can easily add this sort of capability to an ActiveRecord model, without using a plugin, with something like this: class Thing < ActiveRecord::Base validate :happened_at_is_valid_datetime def happened_at_is_valid_datetime errors.add(:happened_at, ‘must be a valid datetime’) if ((DateTime.parse(happened_at) rescue ArgumentError) == ArgumentError) end end

How do I change the default “www.example.com” domain for testing in rails?

Integration/Request Specs (inheriting from ActionDispatch::IntegrationTest): host! ‘my.awesome.host’ See the docs, section 5.1 Helpers Available for Integration Tests. alternatively, configure it globally for request specs at spec_helper.rb level: RSpec.configure do |config| config.before(:each, type: :request) do host! ‘my.awesome.host’ end end Controller Specs (inheriting from ActionController::TestCase) @request.host=”my.awesome.host” See the docs, section 4.4 Instance Variables Available. Feature Specs (through … Read more

What is the replacement for ActionController::Base.relative_url_root?

You should be able to handle all that within the routes.rb file. Wrap all your current routes in scope; for instance. scope “/context_root” do resources :controller resources :another_controller match ‘welcome/’, :to => “welcome#index” root :to => “welcome#index” end You can then verify your routing via the rake routes they should show your routes accordingly, including … Read more

rails paperclip and passenger `is not recognized by the ‘identify’ command`

This is related to ImageMagick. The command_path option needs to point to the location where identify is installed. From the command line, you can determine this with which identify. $ which identify /some/path/to/identify Afterwards, set command_path to that path (in config/environments/development.rb): Paperclip.options[:command_path] = “/some/path/to”