Question

I am eager to try out DataMapper for a new Rails project. I created my project using the following command:

rails new project_name -m http://datamapper.org/templates/rails.rb

I decided to test out my application by running:

rails server

When I go to the generic home page that is created, I can't see any images. I get an error stating:

ActionController::RoutingError (No route matches [GET] "/assets/rails.png")

If I create any other scaffolds and visit those pages, I get similar errors about the stylesheets or javascript not found. I double checked to ensure that a regular Activerecord-rails application worked (which it did). I'm rather puzzled. Any help would be greatly appreciated. Thank you :)

Was it helpful?

Solution

For some reason, DataMapper's Rails template completely replaces the standard Gemfile with their own, which doesn't include any of the asset handling stuff (it also removes a handful of other things like jQuery support, TestUnit, ActionMailer...).

You'll want to add these back in to your Gemfile after setting up the new application:

group :assets do
  gem 'sass-rails',   '~> 3.1.5'
  gem 'coffee-rails', '~> 3.1.1'
  gem 'uglifier', '>= 1.0.3'
end

gem 'jquery-rails'

Per Frederick's suggestion below, you'll also want to add this into your config/application.rb file:

require 'sprockets/railtie'

I opened an Issue and submitted a pull request to fix this.

Update: As of 1/5/2012, this is now fixed. The template behaves nearly identical to a standard Rails 3.1 app with the only change being ActiveRecord being replaced with DataMapper. Assets/jQuery support now works.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top