search for: find_each

Displaying 9 results from an estimated 9 matches for "find_each".

Did you mean: find_cache
2013 Jul 21
4
how to use activemodel collection.build for a has_many :through association
Hi all, In my controller I am doing the following to populate a nested form for a has_many through association: def new @specification = Specification.new Component.find_each.each do |component| @specification.component_specifications.build(:component_id => component.id) end The idea being whenever someone creates or edits a form, it will be populated with all components at that time so that when they save those components that specification will be ass...
2011 Apr 09
4
API documentation for find_in_batches
Hello, At guides.rubyonrails.org I read about the possibilities of find_in_batches. However I cannot find this option anywhere in the API documentation (api.rubyonrails.org). My question: where should I look for the documentation of this command? -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email
2013 Oct 25
6
Migrate postgresql database to uuid
Hi all, I am using rails 3.1 and ruby 1.9.3,Now i want to use uuid concept in rails 3 for existing data so i did like :- create_table :posts, :id => false do |t| t.string :uuid, :limit => 36, :primary => true end ActiveRecord::Base.class_eval do # old rails versions set_primary_key ''uuid'' before_create :generate_uuid def generate_uuid self.id =
2011 Aug 25
3
ActiveRecord searching in batch (with find_by_sql)
I have an issue where I am getting a large number of records from the database and I cant afford to keep it in the memory due to performance issues. Therefore using the following would be ideal, User.find_each(:batch_size => 5000, :start => 2000) do |user| NewsLetter.weekly_deliver(user) end however, I would like to use find_by_sql since my query is user defined. Question is, is it possible to use find_by_sql with batch_size and iterate through all the record-sets? Thanks Bhavesh -- Posted v...
2012 Jan 11
4
ActiveRecord: ar-each_model
Hi, today I went into a problem, when I had to iterate over a big result set. ActiveRecord produces a huge array of model instances, which consumed 1GB of memory on my machine. A comparable perl DBI script only used some KB for iterating over the result set. Then I was suggested to use batch (#find_each) for the problem. But basically batch does the same thing by splitting the query into several queries, which only return 1000 model instances in an array, which still consumes more memory than necessary, but not that much. The problem: it was much slower (it took 25 minutes, while the version witho...
2011 Jul 28
14
Actionmailer Help Needed
...l digest of tasks that are due for a specific user. So far, it''s working but the email only displays the first message. In my task model scope :tasksdue, lambda { where("dueddate > ? AND status = ?", Date.today, false) } def self.send_reminders Task.tasksdue.find_each do |task| TaskMailer.deliver_task_due task end task_mailer.rb class TaskMailer < ActionMailer::Base def task_due(task) recipients @task.user.email from "email-hcDgGtZH8xNBDgjK7y7TUQ@public.gmane.org" subject "Your report entitled" se...
2008 Nov 28
1
True ActiveRecord result set iteration
...er adapters can be extended easily, too. We also tried JRuby 1.1.x, which is sometimes faster than Ruby 1.8.6, but a patch is needed to bring the Java part of the connection adapter into shape for a result set iteration. Okay, you''re about to ask: how does it work. Here we go: MyTable.find_each_by_sql("some SQL here") { |my_table| ... } MyTable.find_each(:all, :conditions => ..., :include => ...) { |my_table| ... } Attached you find the magic code which can be used as a plugin for Rails. When testing, please keep in mind that only Oracle and MySQL is fully supporte...
2009 Aug 20
7
bulk email solutions
i need to send massive emails to various customers, here 2 solutions i have think: 1- customers = Customer.find(:all, :conditions => "newsletter = 1") customers.each do |c| @email = c.email Mailer.deliver_send_newsletter(@subject, @email, @notice_id) end 2- customers = Customer.find(:all, :conditions => "newsletter = 1") customers.each do |c| addresses <<
2010 Mar 10
6
Email section
Sir , I want to implement email section in ma web application.. so i found the method ''server_setting'' for it... Following is the method: config.action_mailer.server_settings = { :address => "smtp.gmail.com" , :port => 25, :domain => "gmail.com" , :authentication => :login, :user_name => "manish" , :password =>