ruby-on-rails-3

Set the Message-ID mail header in Rails3 / ActionMailer

佐手、 提交于 2020-01-20 21:45:30
问题 I would like to alter the Message-ID header that is in the header portion of an email sent from a Ruby on Rails v3 application using ActionMailer. I am using Sendmail on localhost for mail delivery. Do I configure this in Sendmail or ActionMailer? Where do I configure this (if it is ActionMailer): a file in config/ folder or a file in app/mailers/ folder? 回答1: Teddy's answer is good, except that if you actually want each message to have a different ID, you need to make the default a lambda.

Ruby on Rails memory leak when looping through large number of records; find_each doesn't help

泪湿孤枕 提交于 2020-01-20 17:10:46
问题 I have a Rails app that processes a large (millions) number of records in a mysql database. Once it starts working, its memory use quickly grows at a speed of 50MB per second. With tools like oink I was able to narrow down the root cause to one loop that goes through all the records in a big table in the database. I understand if I use something like Person.all.each , all the records will be loaded into memory. However if I switch to find_each , I still see the same memory issue. To further

Ruby on Rails memory leak when looping through large number of records; find_each doesn't help

旧城冷巷雨未停 提交于 2020-01-20 17:09:13
问题 I have a Rails app that processes a large (millions) number of records in a mysql database. Once it starts working, its memory use quickly grows at a speed of 50MB per second. With tools like oink I was able to narrow down the root cause to one loop that goes through all the records in a big table in the database. I understand if I use something like Person.all.each , all the records will be loaded into memory. However if I switch to find_each , I still see the same memory issue. To further

Using Minitest in Rails

和自甴很熟 提交于 2020-01-20 17:03:13
问题 Recently, I've read quite a few articles about Minitest. I really like the idea of a super lightweight test framework. I decided to replace rspec with it in a recent project and have had no luck getting it all to work. My problems are a) getting named routes in my acceptance/integration tests (rspec and test::unit seem to automatically include them but no go with minitest), b) and the overall lack of adoption in rails makes me uneasy (everyone seems to be using rspec though it's used more

Using Minitest in Rails

倖福魔咒の 提交于 2020-01-20 17:00:27
问题 Recently, I've read quite a few articles about Minitest. I really like the idea of a super lightweight test framework. I decided to replace rspec with it in a recent project and have had no luck getting it all to work. My problems are a) getting named routes in my acceptance/integration tests (rspec and test::unit seem to automatically include them but no go with minitest), b) and the overall lack of adoption in rails makes me uneasy (everyone seems to be using rspec though it's used more

Using Minitest in Rails

守給你的承諾、 提交于 2020-01-20 16:58:11
问题 Recently, I've read quite a few articles about Minitest. I really like the idea of a super lightweight test framework. I decided to replace rspec with it in a recent project and have had no luck getting it all to work. My problems are a) getting named routes in my acceptance/integration tests (rspec and test::unit seem to automatically include them but no go with minitest), b) and the overall lack of adoption in rails makes me uneasy (everyone seems to be using rspec though it's used more

is ruby on rails (or at least the community) dying? [closed]

故事扮演 提交于 2020-01-20 16:51:08
问题 As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 9 years ago . This is an honest question and I am not trolling. As a newbie to rails I've been search for good rails resources. But I've been

Use Rails’ form_for but set custom classes, attributes on <form> element?

这一生的挚爱 提交于 2020-01-20 12:27:51
问题 form_for seems to ignore any 'extra' attributes like a data-foo attribute or class passed as options in its second argument. = form_for @user, {:url => 'foo', :class => 'x', 'data-bar' => 'baz' } do |f| # ... The output is a <form> tag with no x class or data-bar attribute. What’s the fix? Or, how can I grab a FormBuilder instance without using form_for ? 回答1: Use the :html hash: = form_for @user, :html => {:class => 'x', 'data-bar' => 'baz'} do |f| Or = form_for @user, html: {class: 'x',

Use Rails’ form_for but set custom classes, attributes on <form> element?

强颜欢笑 提交于 2020-01-20 12:27:47
问题 form_for seems to ignore any 'extra' attributes like a data-foo attribute or class passed as options in its second argument. = form_for @user, {:url => 'foo', :class => 'x', 'data-bar' => 'baz' } do |f| # ... The output is a <form> tag with no x class or data-bar attribute. What’s the fix? Or, how can I grab a FormBuilder instance without using form_for ? 回答1: Use the :html hash: = form_for @user, :html => {:class => 'x', 'data-bar' => 'baz'} do |f| Or = form_for @user, html: {class: 'x',

Devise warden error thrown for authenticate_user in functional Rails test

旧巷老猫 提交于 2020-01-20 03:32:29
问题 I have a resource where the new action requires a user to be logged in to view. If a user tries to create a new resource without being logged in, they are redirected (302'd) to the login page. My functional test looks like this: test "should not get new unless logged in" do get :new assert_response :redirect end The stacktrace looks something like this: ArgumentError: uncaught throw :warden /.../gems/warden-1.1.1/lib/warden/proxy.rb:114:in `throw' /.../gems/ruby-1.9.2-p318/gems/warden-1.1.1