ruby-on-rails-3.1

Rails 3 automatic asset deployment to Amazon CloudFront?

血红的双手。 提交于 2019-12-30 02:09:09
问题 Is there a gem or method available in Rails 3.1 that can upload assets to amazon cloud front automatically and use those instead of serving locally hosted ones? I guess it's easy to upload compiled assets manually and then change the rails app config to use that asset host, but when an asset is modified, the uploads to cloud front would need to be done manually again. Any good ways out there for this? 回答1: Definitely check out asset_sync on github. Or our Heroku dev centre article on Using a

Rails 3 automatic asset deployment to Amazon CloudFront?

六眼飞鱼酱① 提交于 2019-12-30 02:08:00
问题 Is there a gem or method available in Rails 3.1 that can upload assets to amazon cloud front automatically and use those instead of serving locally hosted ones? I guess it's easy to upload compiled assets manually and then change the rails app config to use that asset host, but when an asset is modified, the uploads to cloud front would need to be done manually again. Any good ways out there for this? 回答1: Definitely check out asset_sync on github. Or our Heroku dev centre article on Using a

Turn off verbose sql/ActiveRecord for Rails 3.1.1

和自甴很熟 提交于 2019-12-30 01:53:12
问题 Whereas the verbose feature of SQL/ActiveRecord calls is useful most of the time, I would like to turn it off in cases where I have some looping going on. Is there a way to turn it off? irb(main):055:0> City.first ←[1m←[35mCity Load (1.0ms)←[0m SELECT `cities`.* FROM `cities` LIMIT 1 => #<City id: 1, name: "bla bla", state_id: 1, zip: nil, country_id: nil, created_at: "2011-03-27 14:11:28", updated_at: "2011-08-16 11:14:36", guid: "5PK fvvz2Gsi"> 回答1: In console: Disable: old_logger =

Sass / SCSS Mixin for Clearfix - best approach?

独自空忆成欢 提交于 2019-12-30 00:40:32
问题 I want to remove the clearfix class from my HTML and include a clearfix mixin in my SCSS (Rails 3.1 application). What is the best approach to this? I am thinking of just taking the HTML 5 Boilerplate clearfix and turning it into a mixin, then @including it within the CSS for elements that need clearfixing. Copied from HTML5 Boilerplate: /* The Magnificent Clearfix: Updated to prevent margin-collapsing on child elements. http://j.mp/bestclearfix */ .clearfix:before, .clearfix:after { content:

Rails 3.1 - CSRF ignored?

℡╲_俬逩灬. 提交于 2019-12-30 00:38:11
问题 here my problem, I've got a rails 3.1 app and I'm trying to make an ajax request but I get the warning message "WARNING: Can't verify CSRF token authenticity"… Inside my layout I've got the helper method "csrf_method_tag" , and I add the following javascript code (don't know if it's really required or not): $.ajaxSetup({ beforeSend: function(xhr) { xhr.setRequestHeader('X-CSRF-Token', $('meta[name="csrf-token"]').attr('content')); } }); My Gemfile contains the gem jquery-rails (>= 1.0.12) and

Engine's assets with Rails 3.1

自作多情 提交于 2019-12-29 11:47:23
问题 How should one provide assets in an engine in Rails 3.1? Where should they be located and can they be included automatically? (originally asked by Tomas Celizna) 回答1: The paths to the all the engines' assets folders are automatically loaded. The assets themselves are not loaded by default. This is understandable as the loading is done with require_tree . , which loads all css/js from the current folder (i.e. the main application assets' folder) but doesn't say anything about the engines

trying to get content inside cdata tags in xml file using nokogiri

两盒软妹~` 提交于 2019-12-29 08:27:29
问题 I have seen several things on this, but nothing has seemed to work so far. I am parsing an xml via a url using nokogiri on rails 3 ruby 1.9.2. A snippet of the xml looks like this: <NewsLineText> <![CDATA[ Anna Kendrick is ''obsessed'' with 'Game of Thrones' and loves to cook, particularly creme brulee. ]]> </NewsLineText> I am trying to parse this out to get the text associated with the NewsLineText r = node.at_xpath('.//newslinetext') if node.at_xpath('.//newslinetext') s = node.at_xpath('.

Assets not being run though the .erb preprocessor

醉酒当歌 提交于 2019-12-29 07:11:28
问题 I am having trouble trying to rake assets:precompile in my rails 3.1 app. I keep getting the following error: rake aborted! Invalid CSS after "...und-image: url(": expected ")", was "<%= asset_path(..." It seems that the erb preprocessor is not being invokeb but my file is called style.css.scss.erb . Any suggestions? 回答1: Ruby documentation seems a bit unclear on a few things such as the usage of the asset_path and other such helper in stylesheets. Anyways this is what I did to get around the

Rails how to sum columns?

浪子不回头ぞ 提交于 2019-12-29 06:35:11
问题 Example I have: @test = Pakke.find([[4], [5]]) In my Pakke table I have a column named prismd How do I sum the two values for the prismd columns for @test? 回答1: You can summarize directly on the database by creating the respective SQL like this: Pakke.sum(:prismd, :conditions => {:id => [4,5]}) See ActiveRecord::Calculations for more usage examples and general documentation. 回答2: ActiveRecord has a bunch of built-in calculation methods, including sum: @test = Pakke.where(:id => [4, 5] ).sum(

How do I prevent Rails 3.1 from caching static assets to Rails.cache?

拜拜、爱过 提交于 2019-12-29 04:35:10
问题 I'm using CloudFlare CDN on my Rails 3.1 application. Cloudflare is a CDN that works at the DNS level. On the first hit to a static asset, CloudFlare loads it from your app then caches it in their CDN. Future requests for that asset load from the CDN instead of your app. The problem I'm having is that if you set controller caching to true: config.action_controller.perform_caching = true it enables the Rack::Cache middleware. Since Rails sets a default cache control setting for static assets,