search for: find_first

Displaying 20 results from an estimated 39 matches for "find_first".

Did you mean: find_first2
2005 Nov 23
15
:conditions => ... formatting
With code like: if @params[:pnumber] =~ /\s*p?(\d+)\s*/ if student = Student.find_first(:conditions => ["pnumber like \":pnumber%\"", {:pnumber => $1}]) @borrower = student elsif emp = Employee.find_first(:condiwions => ["pnumber like \"?\"", {:pnumber => $1}]) @borrower = emp else @fla...
2008 Mar 04
6
find_all_by deprecated?
Is find_all_by deprecated and/or find_first_by for 2.0.2? If not, what is actually deprecated? just find_all(..) and find_first()? Thanks for clearing this up. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to thi...
2006 Jan 12
1
A really newbie question
...as or email is found, or create a new record if no matches are found. But despite many tries it just doesn''t work. Did I set the accessor parameters correctly? Thanks. -- class User < ActiveRecord::Base attr_writer :alias, :email def self.newuser?(p_alias, p_email) user = find_first(["alias = ? OR email = ?", p_alias, p_email]) if user.nil? return true else return false end end def self.addupdate(p_alias, p_email) t_user = find_first(["alias = ? OR email = ?", p_alias, p_email]) if t_user.nil? t_user = User.new(:al...
2006 Mar 15
3
Self-referential join model does not work
...hen create two nodes and link them with an edge as follows: >> from_node = Node.create :title => ''From'' >> to_node = Node.create :title => ''To'' >> e = Edge.create :node => from_node, :related_node => to_node >> from_node.edges.find_first.related_node => #<Node:0xb7430ee4 @attributes={"body"=>"", "title"=>"To", "id"=>"2"}> SO FAR SO GOOD! but if I ask the ''from_node'' for ''related_nodes'' this is what I get back!!! >&...
2006 Feb 20
5
find(:all) vs find_all
...ActiveRecord::find() method. I call that sort of API a kitchen sink method because it does so many different things. It really should be multiple methods. And in fact, it used to be! Look in ActiveRecord''s deprecated_finders.rb file. There are three methods in there - find_all, find_first, and find_on_conditions. While I can see an argument for dropping find_on_conditions, the other two seem quite natural, and far preferable to find(:all) and find(:first). Seems like it would simplify things, including the documentation for under what circumstances find() returns a single...
2006 Aug 17
3
file_column do download from URL
Is there a simple way of forcing file_column to download file from given (ex. in form) url instead of uploading it manualy? I know: http://blog.caboo.se/articles/2006/01/09/file_column-magick-and-versions require ''open-uri'' Attachment.find_first.filename = open(url) if not working as expected... what is interesting is that: >> @a = open(''http://www.google.com/intl/pl_ALL/images/logo.gif'') => #<StringIO:0x3c22390> >> @a = open(''http://research.microsoft.com/~dcr/art/lamps/collage/P0002190.JPG...
2013 Mar 28
1
undefined method 'sanitize_limit' for #<ActiveRecord::Relation:0x2aaaad35d720>
...rd-3.1.12/lib/active_record/relation/query_methods.rb:196:in `arel'' /some_package/lib/ruby/gems/1.8/gems/activerecord-3.1.12/lib/active_record/relation.rb:112:in `to_a'' /some_package/lib/ruby/gems/1.8/gems/activerecord-3.1.12/lib/active_record/relation/finder_methods.rb:376:in `find_first'' /some_package/lib/ruby/gems/1.8/gems/activerecord-3.1.12/lib/active_record/relation/finder_methods.rb:122:in `first'' Error is occurred at the execution of following statement: test = where(search_column_name => attributes[search_column_name]).first I found following solutio...
2006 Mar 20
2
AHHHhhhhh... has_and_belongs_to_many, that is going on?
I don''t have a class by the name of "ReviewersScoreCard", yet my many to many configuration looks as follows. And, these errors while running some simple test with ./script/console is giving me a headache: ./script/console Loading development environment. >> r = Reviewer.find_first => #<Reviewer:0x19d0a48 @attributes={"id"=>"1", "first_name"=>"Big", "last_name"=>"Bird"}> >> r.candidates => [#<Candidate:0x19c6340 @attributes={"status"=>"", "id"=>"1...
2006 Jul 01
0
activerecord generating wrong syntax with postgresql
I''m using activerecord outside of rails and find_first generates sql that postgresql doesnt'' like. This is rails 1.1.4, with everything up to date via "gem update". This is the command line: ruby -rrubygems seca -c ../etc/seca.cnf cert --export 1 --format pkcs12 --key root.key >root.pfx This is the error: (PGError: ERROR:...
2006 Apr 13
1
Model is not a class
...sword_confirmation validates_format_of :email, :with => /^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i validates_uniqueness_of :username validates_length_of :password, :within => 6..20 validates_confirmation_of :email, :password def self.authenticate(username, password) find_first(["username=? AND password=?", username, password]) end end and this is my controller: class Account::AuthController < ApplicationController model :account ..... end I guess the problem is that I''m using a module, my controller is inside controllers/account/au...
2006 Apr 17
0
Using variable class names breaks has_many?
Hey All, Any idea why this would work this this: class Dog has_many :fleas end dog = Dog.find_first dog.name => "Buster" dog.class => Dog dog.fleas => [] # store the class animal_class = dog.class => Dog dog = animal_class.find_first dog.name => "Buster" dog.class => Dog dog.fleas => method_missing! # hunh? # but this works ag...
2005 Mar 02
2
Validation question
Hi all, I have something like this : user has_many lists list has_many items I want to validate that the currently logged-in user is the owner of the list an item is being added to. I can do it in "item/create" by doing something like : class item def create @list = List.new( @params[ "list" ][ "id" ] ) if @session[ "user"
2006 Mar 24
6
Should counter_cache fields be saved in the database?
...uot;id"=>1, "parent_id"=>1}, @parent=#<Parent:0x23461d0 @attributes={"name"=>nil, "id"=>"1", "children_count"=>"0"}>> >> parent.children.size => 1 >> parent.children_count => 1 >> Parent.find_first => #<Parent:0x233fee8 @attributes={"name"=>nil, "id"=>"1", "children_count"=>"1"}> >> parent.save => true >> quit [flashbang:...WebContent/rails/development/test] ryann% ./script/console Loading development environme...
2006 Jul 20
1
file_column - assigning with an actual file rather than a multipart
...ng the wonderful file_column and have struck an issue that someone might have seen before. My images already sit on the server. So, instead of passing a multipart message I''m sending a file object. Something like... f = File.new("public/gallery_images/builder.png") p = Product.find_first p.image = f p.save On the save I recieve an error which I''ve pasted at the bottom of this mail. A temporary image is created in the correct place so I''m almost there. Any ideas? I haven''t heard of anyone doing this but file_column.rb#47 said I could. Thanks -h NoM...
2006 Jul 04
1
LoginGenerator Problem
...tes_presence_of :user belongs_to :user end User------------------------------------ require ''digest/sha1'' # this model expects a certain database layout and its based on the name/login pattern. class User < ActiveRecord::Base def self.authenticate(login, pass) find_first(["login = ? AND password = ?", login, sha1(pass)]) end def change_password(pass) update_attribute "password", self.class.sha1(pass) end protected def self.sha1(pass) Digest::SHA1.hexdigest(pass) end before_create :crypt_password def crypt_password...
2006 Feb 27
4
2 belongs_to to the same parent table
Hello! I have 2 table: users and buddies User: id, name, ... Buddy: id, user_id, user_buddy_id, ... So if you have 2 users 1,jack and 2,fred and fred is a buddy of jack, there is a Buddy object: id=1, user_id=1, user_buddy_id=2 I can declare only one belongs_to in Buddy and one has_many in User. And there is conflict if I had the second one (the first one is discarded) class User has_many
2006 Aug 25
0
Re: login sugar
...; /pt/webprops/sysadmin/tst/public/../config/../app/controllers/user_controller.rb:8) > @params is deprecated! Call params.[] instead of @params.[]. Args: > ["user"] (login at > /pt/webprops/sysadmin/tst/public/../config/../app/controllers/user_controller.rb:8) > > WARNING: find_first is deprecated and will be removed from the next Rails > release (find_first at > > /pt/webprops/sysadmin/tst/public/../config/../vendor/rails/activerecord/lib/../../activesupport/lib/active_support/depre > cation.rb:54) > [4;35;1mUser Load (0.001495) SELECT * FROM users WHERE (login...
2005 Mar 23
1
Can't connect to local MySQL server through socket '/tmp/mysql.sock' (61)
.../ruby/gems/1.8/gems/activerecord-1.9.0/lib/active_record/base.rb:732:in `add_conditions!'' /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.9.0/lib/active_record/base.rb:356:in `find_all'' /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.9.0/lib/active_record/base.rb:378:in `find_first'' /app/models/user.rb:7:in `authenticate'' app/controllers/account_controller.rb:12:in `login'' /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.6.0/lib/action_controller/base.rb:691:in `send'' /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.6.0/lib/acti...
2006 Jan 27
1
Multiple Database write question
...ough the same process the app reacts as it should. It is my understanding that when connecting to another DB you do it in the model and than it should connect and update what needs to be changed. My controller looks like this: def info @updateuser = nil if @request.post? @updateuser = User.find_first(["login = ?", @user.login]) @updateuser.lastname = @params[:post][:lastname] @updateuser.firstname= @params[:post][:firstname] @updateuser.prefered_language = @params[:prefered_language] notice = "" if not @params[:post][:password].empty? and not @params[:post] [:passwordb...
2011 Jan 06
4
Not able to insert value in rails console
...3.0.3/lib/active_reco rd/base.rb:467:in `find_by_sql'' from c:/Ruby/lib/ruby/gems/1.9.1/gems/activerecord-3.0.3/lib/active_reco rd/relation.rb:64:in `to_a'' from c:/Ruby/lib/ruby/gems/1.9.1/gems/activerecord-3.0.3/lib/active_reco rd/relation/finder_methods.rb:333:in `find_first'' from c:/Ruby/lib/ruby/gems/1.9.1/gems/activerecord-3.0.3/lib/active_reco rd/relation/finder_methods.rb:122:in `first'' from c:/Ruby/lib/ruby/gems/1.9.1/gems/activerecord-3.0.3/lib/active_reco rd/relation/finder_methods.rb:180:in `exists?'' from c:/R...