ruby-on-rails-3.1

How to change case of interpolated variables in Rails locale file?

拥有回忆 提交于 2019-12-20 20:27:14
问题 Using Rails 3.1.3 with Ruby 1.9.3p0. I've discovered that by default, Rails does not use sentence case for form buttons. For example, instead of an "Update user" button, it generates an "Update User" button. The button names come from the ActionView locale file. Is there a way to create a default that downcases the model name? This is not covered in the Ruby on Rails Guides i18n section on Interpolation so maybe it is not possible. The following doesn't work: en: helpers: submit: update:

Configure session_store.rb to handle staging and production?

喜你入骨 提交于 2019-12-20 18:53:09
问题 I have a staging and a production environment on my rails 3.1rc6 app which uses subdomains. I've bought and configured different domain names for these environments, because the default something-something.herokuapp.com doesn't play nicely with subdomains. When I set session_store.rb to this for one environment, everything works fine: AppName::Application.config.session_store :cookie_store, :key => '_sample_app_session' , :domain => '.mystagingdomain.co.uk' But I can't seem to add in a

Why was auto_link deprecated in Rails?

£可爱£侵袭症+ 提交于 2019-12-20 18:36:10
问题 I realize it's been pulled into a separate gem, but what's the reason? Is this just a matter of streamlining Rails, or is there some reason I should be weary of auto_link? (The gem says it's meant to 'bridge the gap for people migrating', which suggests to me that if I'm introducing rails_autolink into a new project, I must be doing something wrong, no?) thanks, 回答1: From the commit where auto_link was removed, Aaron Patterson (tenderlove) explains in the comments: Unfortunately this method

Why was auto_link deprecated in Rails?

我与影子孤独终老i 提交于 2019-12-20 18:35:07
问题 I realize it's been pulled into a separate gem, but what's the reason? Is this just a matter of streamlining Rails, or is there some reason I should be weary of auto_link? (The gem says it's meant to 'bridge the gap for people migrating', which suggests to me that if I'm introducing rails_autolink into a new project, I must be doing something wrong, no?) thanks, 回答1: From the commit where auto_link was removed, Aaron Patterson (tenderlove) explains in the comments: Unfortunately this method

Assets pipeline when updating to Rails 3.1 on Heroku

独自空忆成欢 提交于 2019-12-20 14:38:54
问题 I've just upgraded my app on Heroku from Rails 3.0 to 3.1, and I'm trying to make the assets pipeline work. The main issue is that I can read from the heroku log the following kind of lines, for every asset: 2011-09-03T16:35:28+00:00 app[web.1]: cache: [GET /assets/border-a3c571a354b9381740db48aeebfaa63a.jpg] miss If I understand the pipeline correctly, this should not be "miss" for every request I make from a browser, but it should be found in the cache. Reading the Heroku docs you can find

Heroku is not pre-compiling my assets to prepare my app for asset pipeline

无人久伴 提交于 2019-12-20 14:13:14
问题 I'm having a bit of trouble getting my asset pipeline setup working with Heroku/Cedar using Rails 3.1.1 I've pushed my application and it launches successfully but there was no message that said "Preparing asset pipeline" and no static assets are being served up. No JS, CSS, or images are able to be found as there is no slug compilation time or runtime asset compilation being done. Any help would be greatly appreciated. They describe what should happen during deployment at this link which I

How can I dynamically require assets in the Rails 3.1 asset pipeline?

六眼飞鱼酱① 提交于 2019-12-20 13:34:41
问题 I have a plugin-based system that I use for application development in Rails. Each plugin implements an engine with MVC components, etc. The main application is simply an empty harness that delegates all the work to the plugins that are installed. I'm currently upgrading to Rails 3.1 from Rails 2.3.5, and am trying to get the asset pipeline working with my framework. The problem I'm having is trying to programmatically require my plugin's assets into, for example, the application.js manifest.

How can I identify unused i18n keys?

让人想犯罪 __ 提交于 2019-12-20 12:31:18
问题 I'm working on an existing Rails app and am using a localization file, en.yml , to hold most of the app's text. At the moment, we aren't localizing into any other languages, so there's just the one file, but the fact that we're putting translate('some.key') into our views means that adding another language will be as simple as adding another file - say, sp.yml The problem is, en.yml has grown to the point that I doubt all the keys are being used. Apart from git grepping for translate calls

Add defer attribute to javascript_include_tag Rails

喜夏-厌秋 提交于 2019-12-20 11:03:46
问题 Is there some way to add the defer attribute easily using the javascript_include_tag helper in Rails? I.e., is there some easy way to turn <%= javascript_include_tag "blah.js" %> into <script defer src="blah.js"></script> 回答1: <%= javascript_include_tag "blah.js", :defer => "defer" %> This will get you (in development): <script defer="defer" src="/assets/blah.js" type="text/javascript"></script> 回答2: You can also do <%= javascript_include_tag "blah.js", defer: true %> which is more consistent

Rails, rake does not work

时光毁灭记忆、已成空白 提交于 2019-12-20 10:38:02
问题 I've been trying to use Rails and when I use rake, I get this error. Any suggestions on which run time should I use? ngzhongqin@ngzhongqin-linux:~/RailsProjects/webuiltit$ rake db:create:all --trace rake aborted! Could not find a JavaScript runtime. See https://github.com/sstephenson/execjs for a list of available runtimes. /home/ngzhongqin/.rvm/gems/ruby-1.9.2-p290/gems/execjs-1.2.4/lib/execjs/runtimes.rb:45:in `autodetect' /home/ngzhongqin/.rvm/gems/ruby-1.9.2-p290/gems/execjs-1.2.4/lib