What is the Ruby on Rails assets directory and how do I get it in my old app?
I'm new to RoR and started making a project recently. The project has public/stylesheets and public/javascripts for my CSS and JS.
For testing purposes, I created another RoR app called sample_app to play around with. I noticed sample_app has an app/assets directory where you can use CoffeeScript开发者_运维问答 and SCSS! That's really cool!
However, my primary app doesn't have that stuff.
Can someone explain what is going on here, and how do I upgrade my first app to use CoffeeScript?
Also, does it matter that my first app has a model called Asset? I could rename it if necessary... heck, I could just create a new app if necessary and move all the old code over manually. It'd be worth it to use CoffeeScript instead of JS.
Thanks!
Rails 3.1 is currently in beta (technically, release candidate 3.1.0.rc1).
Take a look at the generated files in sample_app. Particularly config/*
, config/initializers/*
. Copy any differences to your existing app.
- Replace the
gem 'rails'
line withgem 'rails', '3.1.0.rc1'
in your existing app's Gemfile. - Copy app/assets to your existing app
- Run
bundle update
rails generate controller some_test_controller
will give you an idea of where Rails is putting/using the new app/assets.- Move things from
public/javascripts
andpublic/stylesheets
toapp/assets/**/*
Keep in mind, rails-3.1.0.rc1 should be fairly solid, but it is a beta release. Make sure you've got stuff committed / backed up before starting
精彩评论