similar to: Find first or create

Displaying 20 results from an estimated 10000 matches similar to: "Find first or create"

2010 Jul 12
0
[Patch][Issue #5097] attributeless find_or_create/find_or_initialize
This patch relaxes DynamicFinderMatch to recognize find_or_create / find_or_initialize without a trailing _by_attribute_list. I''ve found this useful when the relevant attributes have already been built up through a chain of associations or named scopes. Please review, thank you! -- You received this message because you are subscribed to the Google Groups "Ruby on Rails:
2007 Mar 16
1
Polymorphic find_or_create bug
Today I just spent 3 hours (and before a demo!) trying to figure out why my polymorphic association fields were breaking. Turns out someone else put in a patch for this 6 months ago. I''m not sure if its the same solution I''d use... I''d rather find_or_create attempt to use AssociationProxy#build if its available and only Base#new if we''re not on a proxy.
2009 May 28
1
:has_many and :after_save
Having one to many connection (for example post has many comments), what is the most efficient way of saving all comments when post is saved. Using after_save on Post would introduce the n+1 problem. Is there any way of saving the whole structure at once? -- Posted via http://www.ruby-forum.com/.
2009 Apr 28
1
chmod in rails development
What chmod value I am supposed to use for rails app development? Is 777 a good idea? Or should I use sudo when I run my commands (such as script/server)? -- Posted via http://www.ruby-forum.com/.
2009 Sep 22
6
Import excel / csv files
Hey, What way is the best to do imports of CSV files?
2006 Feb 24
6
Duplicate entry - how to check if an id exist before saving?
How do I check if an entry exists before saving? Someone one told me to use the method find_or_create (or something like that) but it didn''t work because I think the version of rails that we have is not the most recent. I need a way to check if an id exists in the db before saving. Any suggestions? Thank you -- Posted via http://www.ruby-forum.com/.
2009 Oct 11
0
Nested Attributes and find_or_create
Hi, I''m using the new Nested Attributes to edit my models. It''s a complicated relationship between 5 different models which are subclassed from a ''Metadata'' model. They all have has_and_belongs_to_many relationships with the model I am trying to edit. Unfortunately when I add a new nested attribute, it creates a new row in the database. I need it to check up
2012 Jan 04
1
AR update / create pattern: is there an easier way?
I find myself writing the following frequently: r = MyActiveRecord.where(:attr1 => cond1, :attr2 => cond2, ...) r.exists? ? r.first : r.create ... which has the effect of returning an instance of MyActiveRecord if all the conditions are met, or creating one if it doesn''t. A variant of this: c = MyActiveRecord.new(:attr1 => val1, :attr2 => val2, ...) r =
2008 Feb 08
4
x-post : find_or_initialize_by ActiveRecord bug? Ignores :conditions
Hello, I posted this on the rails talk group but received no response. Perhaps someone on this list could weigh in on whether this is expected/desired behavior or a bug that I should file and develop failing tests for (I doubt I have the active record method_missing fu to actually patch it). Test Scenario: I would like to find or initialize a new user and base the find on the users email
2012 Feb 22
3
Parent id for find_or_create method
Rails 3.1.3 I have tables, Video and Script having association, Video 1 --- n Script So, every Script needs the parent id, in this case, video_id. If I simply create a new Script instance, the view renders as follows. <%= render :partial => "new_script", :locals => { :script => Script.new(:video_id => @video.id)} %> which works fine. Now I would like to
2012 Jul 24
4
Behavior of first_or_create
I just ran across a weird glitch (IMHO) in find_or_create. The arguments passed to it are *not* added to the conditions for the ''first'' part. This is odd, given that it''s intended to replace find_or_create_by_* methods, which *did* use the specified values as conditions. I''m unsure on whether this behavior is entirely undesirable, but it''s definitely
2007 Dec 10
8
could not find activerecord-sqlserver-adapter locally or in a repository
I''m trying to connect to a SQL Server db. I thought I installed the DBI component per the instructions, but its not working. When trying to start the ruby server, I get the message: Please install the sqlserver adapter: `gem install activerecord- sqlserver-adapter` But when I try to install the repository, I get this error message: could not find activerecord-sqlserver-adapter
2006 Aug 02
1
ActiveRecord: find_or_create with has_and_belongs_to_many --
I am attempting to use find_or_create on a foreign table with a has_and_belongs_to_many relationship with my current table. I am doing the following: term = school.terms.find_or_create_by_code("FALL06") the queries in the log show the expected SELECT statement to query if there is a join table record between the school and term with code "FALL06": SELECT * FROM term INNER
2019 Apr 21
3
FTS delays
On 3 Apr 2019, at 20.30, Joan Moreau via dovecot <dovecot at dovecot.org> wrote: > doveadm search -u jom at grosjo.net mailbox inbox text milan > output > > doveadm(jom at grosjo.net): Info: Query : ( bcc:inbox OR body:inbox OR cc:inbox OR from:inbox OR message-id:inbox OR subject:inbox OR to:inbox OR uid:inbox ) AND ( bcc:milan OR body:milan OR cc:milan OR from:milan OR
2008 Aug 31
9
assigning collection values and exceptions
hi everyone, I''ve this code in my Report model: has_many :report_reasons, :validate => true has_many :reasons, :through => :report_reasons #, :uniq => true # :accessible => true def reason_attributes=(reason_attributes) reasons.clear reason_attributes.uniq.each do |reason| reasons << Reason.find_or_create_by_content(reason) end end
2019 Apr 02
3
FTS delays
On 2 Apr 2019, at 6.38, Joan Moreau via dovecot <dovecot at dovecot.org> wrote: > > Further on this topic: > > > > When choosing any headers in the search box, dovecot core calls the plugin TWICE (and returns the results quickly, but not immediatly after getting the IDs from the plugins) > > When choosing the BODY search, dovecot core calls the plugin ONCE (and
2019 Apr 21
2
FTS delays
Inbox appears in the list of arguments, because fts_backend_xapian_lookup() is parsing the search args wrong. Not sure about the other issue. > On 21 Apr 2019, at 19.31, Joan Moreau <jom at grosjo.net> wrote: > > For this first point, the problem is that dovecot core sends TWICE the request and "Inbox" appears in the list of arguments ! (inbox shall serve to select teh
2019 Apr 21
2
FTS delays
It's because you're misunderstanding how the lookup() function works. It gets ALL the search parameters, including the "mailbox inbox". This is intentional, and not a bug. Two reasons being: 1) The FTS plugin in theory could support indexing/searching any kinds of searches, not just regular word searches. So I didn't want to limit it unnecessarily. 2) Especially with
2004 Sep 09
1
php-snmp *UPDATE*
Thank you to all the people that responded. I found a php.spec file for EL3 and modified the php.spec file that came with the php source rpm from the CentOS mirros. Built and installed the php-snmp rpm and it is working great!!! For anyone that would like to have a copy for themselves can find it at http://traffic.wonderwave.net I will leave it up for a week or two so act fast. I also posted the
2010 Aug 30
10
Trouble with rvm (Ruby Version Manager)
Hi-- Am having trouble with rvm. Successfully installed it, but when I tried to install Ruby 1.8.7, here is the error I got: Paul-Denlingers-MacBook-Pro:~ pdenlinger$ rvm install 1.8.7 -bash: rvm: command not found Tried closing terminal, quitting terminal, opening another tab, etc. but continued to get same error. What to do? Thanks! -- You received this message because you are subscribed