similar to: x-post : find_or_initialize_by ActiveRecord bug? Ignores :conditions

Displaying 20 results from an estimated 3000 matches similar to: "x-post : find_or_initialize_by ActiveRecord bug? Ignores :conditions"

2008 Feb 07
1
ActiveRecord 'find_or_initialize_by' dynamic finder bug? Ignoring conditions.
Hello all, I just ran into something that I think is a bug, and I would like to confirm with the core team whether this is expected/desired behavior or if this is 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
2006 Oct 21
0
find_or_initialize_by and Nested Resources
Hey guys, Lets say I have the following nested resources: map.resource artists do |artists| map.resource songs end To create a new song, the url would be: /artists/:artist_id/songs/:song_id However, lets say that an artist doesn''t exist yet. I only want to create an artist if a new song by the artist is successfully saved. I am retrieving the artist using something like: @artist
2008 Feb 07
1
field names, aliases and finders.
I can not seem to make finders work with aliases. My goal is to map some fugly field names to nice field names and have the finders work with the nice field names. An example. class Users < ActiveRecord::Base alias :password :UserPWD end This doesn''t seem to work because obviously the object doesn''t have a method called UserPWD. What is the best way (short of a view) to
2007 Nov 23
2
Create my own dynamic "finder" method?
Hi all I''m having an authorization method that looks like the following: def user_requests_authorization_to(right_name) ... end I find it boring to always use user_requests_authorization_to(''EDIT'') user_requests_authorization_to(''CREATE'') etc., so I thought I could implement my own dynamic method, like the dynamic finders! Instead of the calls
2011 Aug 23
2
Where is WillPaginate::Finders ???
Hi All! It''s been a while since I had to ask for help, but I''m back! I''ve finished beta testing my big app and started the transition to production. Everything went fine and the production version was working till I was asked to add another model :-( (Almost a year of beta testing and they only come up with it after moving to production :-D ) I successfully
2006 Jan 05
8
Repost - Do dynamic finders work with legacy schemas?
Hello everyone, I have another question related to a legacy schema I am working with. Do dynamic finders work with legacy schemas in general? The schema I am working with uses hungarian prefixes for column names. For example fOpen is 0 if a bug is closed and 1 if it is open (type smallint). When I try @bugs = Bug.find_all_by_fOpen(1), I get the following exception: undefined method
2007 Oct 26
1
Spec custom finders
I have some finders in my models where I write some of the sql myself. I of course want to test these, but am not sure the best way. Should I just let them roll through to the db, and verify they return the correct objects based on the fixtures I load, or should I spec the actual query? I know that DB access is sort of frowned upon, but is this a situation where it is more or less acceptable? My
2006 Jan 26
2
Easy way to add properties to a model?
Hi, I have a model (let''s say User) and I would like to add any number of user-defined-settings to this Model. I created a UserSetting Model with user_id, key and value. I connected them with has_many. I know how to access these properties from a user but I would like some methods like user.hasProperty? / user.getProperty ... I think I know how to write these methods/finders myself but
2007 Aug 18
12
Test::Unit to RSpec
So I''ve just started working on a rails project which currently has something like 7500 LOC. All of the tests are written in Test::Unit, although the test coverage is pretty poor: rcov says that 25% of the code is covered, while rake stats shows the code to test ratio as 1:0.1 (800 lines of test code). I guess I''m wondering what would generally be advisable here. Is it
2006 Apr 11
2
Getting distinct years from a date column the Rails way
I have an original_at column in my photos table. I''d like to get a list of distinct years that occur in this column, and some of the values are NULL. I see two ways of doing this. The SQLish way: photos = Photo.find :all, :select => ''distinct year(original_at)'' This is efficient in that it utilizes the database to do the filtering, and the code is not too ugly.
2007 Jan 09
1
some Maildir files not honoring dovecot-shared
I'm using RC15 on Solaris 9. The wiki indicates that when a dovecot-shared file exists, "Dovecot uses the same permissions and GID when it creates index files, dovecot-uidlist file, new mail files, etc." In my case, Dovecot *is* creating new index files based on dovecot-shared, but dovecot-uidlist and individual message files don't completely match the permissions/group
2010 Sep 23
4
CentOS, Firefox, and Java Plugin
The latest updates to CentOS 5.5 seem to have broken the Java plugin, and have defeated any and all attempts to get it working again. I'm running CentOS 5.5 (32-bit) and Firefox 3.6.9 (installed from the CentOS repository); I've tried BOTH the openJDK plugin available through the Argeo repositories, and installing Java 1.6.0 directly from Sun/Oracle and creating the plugin soft link in
2006 Jul 26
1
Polymorphic Associations: dynamic finders
Is there any sort of dynamic finder for polymorphic associations? For example if I had: class InviteNode < ActiveRecord::Base belongs_to :inviteable, :polymorphic => true end I would like to be able to search by: InviteNode.find_by_inviteable(some_object) instead of having to do: InviteNode.find_by_inviteable_id_and_inviteable_type(some_object.id, some_object.class.name) obviously I
2007 Oct 03
2
rails:freeze:edge task is broken [updating to 2.0]
On 10/3/07, Glenn Rempe <glenn.rempe@gmail.com> wrote: > > > You may want to also take a look at this bug report that I filed. I > had the same problem and running the ''rake rails:freeze:edge > TAG=rel_2-0-0_PR'' TWO times resolved the issue for me when upgrading a > 1.2.3 app. Explanation in the bug report. > >
2006 May 18
7
Server out to excel
How would one server out to excel a html table with the mime/content type application/vnd.ms-excel ? In PHP it would be something like ?php header("Content-Type: application/vnd.ms-excel"); ------ But how do I do this in rails? Cheers Glenn -- Posted via http://www.ruby-forum.com/.
2004 Sep 10
4
OS X compile errors
On Tuesday, January 7, 2003, at 10:15 PM, Josh Coalson wrote: > I am going to check in a fix soon that will be in flac-1.0.5-beta2. > In the meantime you can manually add -Dunix to the two assignments > of OUR_CFLAGS_TAIL in configure. I tried that fix, ran `make clean; ./configure --prefix=/opt` then: [TLB:~/Desktop/flac-1.0.5_beta1/flac-1.0.5_beta1] glenn% make make all-recursive
2009 Jan 14
6
Removing duplicates from a list
For a list say; list1<-{1,2,3,4,5,2,1} How do I remove the duplicates please? My real list is 20,000 obs long of dates with many duplicates Regards Glenn [[alternative HTML version deleted]]
2004 Mar 02
7
Cisco IP Phones
We have worked with some of you supplying Cisco IP phones to use with your Asterisk system. We have a good supply of new and used Cisco IP phones (CP-7905, CP-7940 and CP-7960) at this time. All of our equipment carries a 90-day warranty. If we can help you out with any of your phone, router or switch needs, please let me know. Thanks, Jon Putnam Global Technology Solutions main #763-488-1870
2008 Mar 18
4
Can an object obj-arbitrary respond to a method with arbitary name?
For example: I create an object c. Now, if I call c.xxx, ruby just raise an exception ''method missing'' But, I want it return nil, for each method which is not pre-defined. Is there a way I can gain this ? Thanks! --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To
2006 Apr 02
2
Delaying table attribute load using ActiveRecord
Hi all, I came accross the following problem lately: I got a table with several BLOB fields (Oracle DB) and I have ActiveRecord reading those fields whenever records are loaded using finder methods. This behavior is just fine in 99.9% of the time, but considering BLOB data is not small, it is considerably slowing down search access :(. So basically, I thought about building a :has_one