简体   繁体   中英

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 with gem '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 and public/stylesheets to app/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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM