search for: find_by

Displaying 20 results from an estimated 26 matches for "find_by".

Did you mean: find_by_
2006 Jun 14
1
Partial matches with find_by
I have a form passing a parameter to a "show_search" action. Everything goes fine, as long as i search for the exact title of the post. How do I do a partial or "wild card" search? Code below: def show_search @posts = Post.find_all_by_title(params[:title]) end -- Posted via http://www.ruby-forum.com/.
2006 Jan 03
1
find_by datetime question
Hi, I was wondering if any of you Rails/SQL ninjas knew of an elegant way to grab from activerecord all the rows that are within an interval of the current time (say in the last week). For instance, if there''s the created_on datetime column, is there a zippy way to use find() without SQL? It seems like the Ruby DateTime object doesn''t really do intervals for numerous
2006 Jan 07
1
Difference in find_by
...is between the "@params" and "params". (I know the first is a instance variable and the second is a ''normal'' variable. What does this mean in pratical terms? @contact = Contact.find(@params[''contact''][''id'']) @user = User.find_by_firstname(params[:user][:firstname]) Regards, Gerard. -- "Who cares if it doesn''t do anything? It was made with our new Triple-Iso-Bifurcated-Krypton-Gate-MOS process ..." My $Grtz =~ Gerard; ~ :wq!
2010 Nov 28
2
Dynamic find_by method returning nil in a class method
...> true, :length => {:within => 6..20}, :confirmation => true validates :sex, :presence => true validates :birth_date, :presence => true def self.authenticate(email, submitted_password) user = find_by_email(email) puts user return nil if user.nil? return user if user.has_password?(submitted_password) end end as you can see I left out some code but the problem I am having is where you can see that I have a "puts user". when running this method from the Console like so U...
2006 Aug 02
3
find_by_column_name and for loop returns undef method `each''
I''m trying to understand how to select only certain rows in my database using RoR. As a test I try to find certain clients by adding this code in my list view... <% clientlist = Client.find_by_client_status_id(1) %> <% if clientlist %> <= This prevents me from getting nil errors. <% for client in clientlist %> <= This seems to try and call ''each'' method. ... <tr> and <td> data display ... <% end %> <% end %> My clien...
2013 May 28
3
AR's find_by_* limits return results. How to avoid id?
When I use find_by_name method I get LIMIT 1 result. > SELECT "users".* FROM "users" WHERE "users"."age" = 25 LIMIT 1 But the "age" column is not unique in my table and its value may repeat. So I expect that an array of records where "age" is 25 will be...
2007 Mar 27
6
how does rails do this "find_by_?"
Hello there, I''m wondering how do they create functions on the fly? find_by_any_column_name ?? I want to do something similar with my models, but I don''t really know how to do it? user_current_nickname user_current_id user_current_role etc.? Regards, Jamal -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You re...
2006 Apr 20
7
Rails + postgres case insensitive searches.
Hello all I am wondering how rails handles case sensitivity in databases. If I do a Person.find_all_by_name("tim") in mysql I would expect to get tim, TIm, and Tim. Do I only get tim in postgres? How do other people deal with this? Do you resort to find_by_sql for all your postgres queries to get case insensitive results?
2006 Apr 29
7
catch "find" exception
obviously, follow code is not working <p> <% if !@group.users.find(session[:user].id) %> <%= link_to "Join This Group", :action => "join", :id => @group %> <% end %> </p> "find" always throw an exception. I want to display the link of "find" fails, what is the right way to do this? Thanks. -- Posted via
2007 Dec 22
8
Rails 2.0 rescue_from
I am trying to use the new Rails 2.0 macro : rescue_from class PostsController < ApplicationController rescue_from ActiveRecord::RecordNotFound, :with => :deny_access ... def show @post = Post.find_by_id(params[:id]) raise ActiveRecord::RecordNotFound if @post.nil? #illegal access ..... end def deny_access respond_to do |format| format.html end end but the exception is not raised ... did I miss something ? thanks kad -- Posted via http://www.ruby-forum.com/. --~--~...
2006 Aug 09
2
newbie problem with FIND
hi! how can i find an ID from a table, with another attribute? i mean, i have the table users, with id, and name, and i want to find the id, where the name is. i know only the way with the id.. @something = User.find(params[:id]) which would be the correct syntax? ty!! -- Posted via http://www.ruby-forum.com/.
2006 Mar 14
1
Dynamic Finders with _or_create Don''t Work?
What could cause this? >> sdfl=PartNumber.find_by_part_number("1111111") => #<PartNumber:0xb78fc744 @attributes={"id"=>"11601", "part_number"=>"1111111"}> >> sdfl=PartNumber.find_or_create_by_part_number("1111111") NoMethodError: undefined method `find_or_create_by_p...
2006 Oct 17
0
TypeError (can't convert Bignum into Hash):
.../lib/active_record/connection_adapters/mysql_adapter.rb:342:in `select'' /usr/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_record/connection_adapters/mysql_adapter.rb:175:in `select_all'' /usr/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_record/base.rb:390:in `find_by_sql'' but it comes from several different find_by calls. find_by_sql and find_by_id I''m running Rails 1.16 with ruby 1.84 on Mongrel 0.3.13.4 behind Apache 2.23 on Debian 3.1r3 with MySql 4.1 Anyone seen this or got ideas on how to further track this down?? Thanks Sam -- Pos...
2008 Sep 23
0
Questions on Active Record SQL type Finders & Dynamic Finder
Hi, I understand there are total 11 types of key Options for finding a record. The all 11 valid keys for the options hash are :conditions, :include, :order, :select, :group, :joins, :from, :limit, :offset, :readonly, and :lock. We also have Dynamic Finders for the same. e.g. ... find_by etc... I would like to know, how many types of dynamic finders, Active Record provides, to match all those 11 key options above. Where can i read more details regarding dynamic finders...? Thanks -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ Yo...
2011 Apr 01
0
Netsuite data fetch
Hello Friends, I have a requirement where I need to fetch netsuite Inventory Items, for the same I am using "netsuite_client" gem but somehow I can only fetch a single record via "client.find_by(''ItemSearchBasic'', " method is there any way I can fetch all the inventory items.. Thanks for any help any suggestion. Abhis -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send ema...
2014 Apr 14
0
Pairing Data 2-D array
I have class A. I have a class B with attributes c and d. A has many Bs. I get an instance of A using a = find_by.... I can get a listing (enumeration) of values for attribute b using map function. a.b.map{ |x| x.c} c1 c2 c3 However, I want c and d returned and paired together in an array like a 2-d array. c1 d1 c2 d2 c3 c3 What's the best way to do this? Map won't work, correct? -- Post...
2006 Apr 07
2
MSSQL activerecord uses bad syntax
Hi all, I''m trying to get rails up on mssql for a friend, does anyone have experience? We''re working on a Windows XP box with MSSQL 2000 (no service pak), and both rails (1.1) and MSSQL are on the same box. I''m running into a bug (I think) where activerecord is using this syntax: SELECT TOP 1 * FROM users WHERE (users.user = ''jbgnuumnbu'')
2007 Sep 10
6
RSpec view spec writing problem (unable to generate url_for in RESTful resource link_to)
...<li> 22: <%= link_to(a.name,actor_path(@customer, at project),{:class=>"show",:title=>"Show actor details"}) -%> 23: <%= link_to("Remove assignment",participation_path(@customer, at project, at use_case.participations.find_by _actor_id(a)),{:class=>"delete",:title=>"Remove the assignment of this actor to this use case", :confirm => ''Are you sur e you want to remove this assignment?'', :method => :delete})-%> 24: </li> 25: <% end %>...
2006 Jan 31
2
Relationship navigation issue
...:category end class Venue < ActiveRecord::Base belongs_to :city end class City < ActiveRecord::Base belongs_to :state end I want to retrieve all event records belonging to a state. Coming from hibernate background I tried something like this: def self.list_for_a_state(state_id) find_by_sql(["select e.* from venues v, events e where v.city.state_id=? and e.venue_id = v.id",state_id]) end Error: Unknown table ''v.city'' in where clause How do I handle this case? Thanks. -------------- next part -------------- An HTML attachment was scrubbed... URL: htt...
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 this group, send email to