ruby-on-rails-3

Where to store site specific information like site name, admin email, etc?

强颜欢笑 提交于 2019-12-23 11:34:19
问题 When creating say a cms application where website specific details will vary depending on the website, where should I be storing this information? Things like: site name, support email, smtp settings, etc.? 回答1: Assuming you mean configuration data for the application, here's what I do: I create a config/app_config.yml file with my config information, like this: site_name: This awesome site support_email: me@mysite.com Then, at the top of config/application.rb (right below the first 'require'

How to define custom templates with foreman's --template option?

只愿长相守 提交于 2019-12-23 11:26:07
问题 While using the foreman gem I'm having some issues where it will not allow me to define a custom template. For one of my apps I am able to define ~/.foreman/templates/upstart/master.conf.erb and it is read just fine. Yet for another project, no matter what I try, I cannot get a template to evoke properly with forman upstart exportation. I've attempted many different ways from defining the -t and --template flag with a file with absolute and relative paths to the ~/.foreman approach. Nothing

Calling Controller Method in link_to from the view

好久不见. 提交于 2019-12-23 10:54:51
问题 My application has deals which have orders. In my admin area I want to be able to process the orders manually. In my access/deals view <%= link_to "Process Orders", "Not sure what I put here?" %> in my access/deals_controller def process_orders @deals = Deal.find(params[:id] @orders = @deals.orders.where("state" == ?, "pending") @orders.each do |order| #order processing code here end end How should I structure my link_to method to call the process_orders method in my admin/deals controller? I

Overriding backend assets in production environment

烈酒焚心 提交于 2019-12-23 10:50:14
问题 I am working on a project that needs to alter Refinery's WYMEditor behavior a bit. This is easily done by overriding jquery.refinery.wymeditor.js using rake refinery:override and editing it to my own needs, which works fine in development environment. However, when it comes to production, overrides are ignored. That is, the compiled asset just contains jquery.refinery.wymeditor.js from bundle, and editing that file directly there may give the desired effect, but that's just not the way it

Ruby: Mail gem add \r\n after 60 chars in mail

泄露秘密 提交于 2019-12-23 10:44:42
问题 I want to port actionmailer_x509 to Rails 3. In order to do that I try to create Mail object from big string with signed email. You can see such creation on this line: https://github.com/petRUShka/actionmailer_x509/blob/master/lib/actionmailer_x509.rb#L129 Original string ( smime0 ): https://gist.github.com/1d2c84cc2e255be010a6 Resulted Mail object dumped to file( newm ): https://gist.github.com/4682fe88e8dcfeca60b2 For example, you can see the difference between line 26 of smime0 and line 40

Ruby: Mail gem add \r\n after 60 chars in mail

≡放荡痞女 提交于 2019-12-23 10:43:07
问题 I want to port actionmailer_x509 to Rails 3. In order to do that I try to create Mail object from big string with signed email. You can see such creation on this line: https://github.com/petRUShka/actionmailer_x509/blob/master/lib/actionmailer_x509.rb#L129 Original string ( smime0 ): https://gist.github.com/1d2c84cc2e255be010a6 Resulted Mail object dumped to file( newm ): https://gist.github.com/4682fe88e8dcfeca60b2 For example, you can see the difference between line 26 of smime0 and line 40

How do I specify different versions of a gem for development and production

人盡茶涼 提交于 2019-12-23 10:20:02
问题 I need to have different versions of a gem for development and production, so I put the following in my gemfile. group :development, :test do gem 'rspec-rails', '2.11.0' gem 'bcrypt-ruby', '3.1.2' end group :production do gem 'rails_12factor' gem 'bcrypt-ruby', '3.0.1' end but if i try to do bundle install or even just rails console I get the above error I have tried bundle install --without production but I still get the error message. FYI: I need to do this because I am going thru the rails

Setting Excel column widths correctly when adding to spreadsheet via Axlsx

血红的双手。 提交于 2019-12-23 10:15:43
问题 I'm trying to format my report and making sure the columns have a correct width and I can't seem to make it happen with auto_width. With this code, this is the kind of report I get . Notice the space that is way to long for an auto_width, since if I double click on each column border in Excel, it correctly resizes, see this picture . Maybe it's the order I'm doing things? This is the code I'm using: workbook = xlsx_package.workbook worksheet_name = 'My Worksheet' xlsx_package.use_autowidth =

Including assets in subdirectories with config.assets.precompile in Rails

淺唱寂寞╮ 提交于 2019-12-23 10:10:03
问题 I've got a Rails 3.1.3 application running on Heroku, utilizing S3 for asset hosting via asset_sync . Included in my app/assets/css directory is a subdirectory with two files: main.css.scss and categories.css.scss . I have the following line in my production.rb : config.assets.precompile += [ 'admin/main.css.scss', 'admin/categories.css.scss', 'print.css', 'products.css.scss', 'services.css.scss' ] When I push to Heroku, all my assets are precompiled and uploaded with the exception of those

Nested attributes not showing up in simple form

拥有回忆 提交于 2019-12-23 10:09:02
问题 Given the following: Models class Location < ActiveRecord::Base has_many :games end class Game < ActiveRecord::Base validates_presence_of :sport_type has_one :location accepts_nested_attributes_for :location end Controller def new @game = Game.new end View (form) <%= simple_form_for @game do |f| %> <%= f.input :sport_type %> <%= f.input :description %> <%= f.simple_fields_for :location do |location_form| %> <%= location_form.input :city %> <% end %> <%= f.button :submit %> <% end %> Why the