similar to: how does rails do this "find_by_?"

Displaying 20 results from an estimated 2000 matches similar to: "how does rails do this "find_by_?""

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 returned. But AR limits the query by 1. How to avoid it? Or is it the default
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
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
2007 Nov 25
4
is notify resevered word?
Hi, When I added this association... class User < ActiveRecord::Base has_one :notify end ...and tried then to update column in User table it will call queries for notify table automatic? Output --------------------------------------------------------------- User Columns (0.041488) SHOW FIELDS FROM `users` User Load (0.001544) SELECT * FROM `users` WHERE (`users`.`nickname` =
2005 Dec 14
4
find_by_ issue
In the Agile RoR book, page 219 (softcover version) they talk about the fact you can use the methods: find_by_ and find_all_by_ and fill in the last piece with a valid column name. So I have a database table called "parts" and the following columns: id partname partnumber vendor I do the following: (connection to DB already established) class Part < ActiveRecord::Base end
2007 Nov 01
3
autotest debugger?
Hi, I keep facing problems with autotest, and I don''t know what''s happening in the background, is there anyway to know what''s happening while testing? Example: @user = User.new @user.email = "testcom" @user.errors.on(:email).should_not be_empty ...throws error failure - You have a nil object when you didn''t expect it! - You might have expected an
2007 May 06
2
render :action "call method first?"
Hi, I know when I call: render :controller => ''some'', :action => ''thing'' It doesn''t call the method ''thing'' before render the template ''thing.rhtml'', but I need some instance variable which are in the ''thing'' method, how can I let it call the method ''thing'' and then render
2010 Sep 09
17
formtastic issue
Hello, I will try to explain it step by step :-) I just created a new rails 3 app, then I created a new controller... rails generate controller admin::users I didn''t forget to add the resources in the routes.rb file like this. namespace :admin do resources :users end Now I try to use formtastic to create the form but I get erorr that my users_path doesn''t exist?
2007 Oct 29
2
rspec throws exception (nameError)
Hi, I''m running Rails 1.2.5 with rspec 1.0.8. When i runned autotest first time, it complained about this line. #include ActionView::Helpers::JavaScriptMacrosHelper in vendor/plugins/rspec_on_rails/lib/spec/rails/dls/behaviour/helper.rb ...I commented it out, then I got another error about this line, so I also commented this out. #Test::Unit.run = true in
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_part_number'' for PartNumber:Class
2007 Sep 07
5
enforce mutual exclusivity
Hi, First post, please be gentle! I couldn''t find any mention of this already I''m using ActiveRecord and I want to enforce mutual exclusivity on a has_and_belongs_to_many. A concrete example: I have a User which can have one or more Roles (student, tutor, headmaster, administrator etc). However if a user is a student they cannot hold any other role. I was hoping to find
2007 Oct 02
3
Note on Rails 2.0 Preview
Make sure you get a relatively current version of rspec or you will get: /Users/me/rails/ubb/vendor/rails/activerecord/lib/../../activesupport/ lib/active_support/dependencies.rb:263:in `load_missing_constant'': uninitialized constant ActionView::Helpers::JavaScriptMacrosHelper (NameError) Hope this helps someone.
2007 Mar 01
1
RoR: Torrent Tracker
Hello their, I managed to find torrent tracker made in RoR language, now I downloaded and trying to run it, but I get error saying: Could not find RubyGem bencode (>= 0.0.0) I don''t know where i can get the bencode, anyone can help please :) require_gem ''bencode'' regards, Jamal -- Posted via http://www.ruby-forum.com/.
2007 Apr 12
4
Installing rspec in Windows
Hi all, I''m trying to install rspec and I''m having a problem. C:\Users\Nathan\Documents\rails\myproject> gem install rspec Bulk updating Gem source index for: http://gems.rubyforge.org Successfully installed rspec-0.8.2 Installing ri documentation for rspec-0.8.2... Installing RDoc documentation for rspec-0.8.2... C:\Users\Nathan\Documents\rails\myproject> ruby
2007 Mar 29
4
validates_length_of not working with :if ?
Hello, I''m trying to cut down the errors if the guy already getting the empty nickname, so he doesn''t get anything about the nickname is short. validates_presence_of :nickname This below is not working ? validates_length_of :nickname, :within => 4..40, :if => Proc.new { |user| user.nickname.length > 1 } nor this one below? validates_length_of :nickname, :within
2008 May 22
9
Retrieving Mutliple Records using find_by_*
I was hoping that AR''s find_by_* magic methods would help me retrieve multiple items somewhat like the following: names_to_find = [''Larry'', ''Moe'', ''Curly''] found_people = Person.find_by_name(names_to_find) Is there a way to accomplish this using find_by_* (or even find(:all) using some sort of conditions) or must I resort to SQL
2006 Nov 16
2
dynamically adding static (class) methods to a class
Hello again, I guess this is more of a Ruby question, but here goes anyways... I want to intercept all calls to non existent class methods and then call an existing class method with the non existent name. In code... class MyModel < ActiveRecord::Base def MyModel.method_missing(symbol, *args) MyModel.func(symbol.id2name) end def MyModel.func(func_called) puts "You
2006 Jan 23
2
where are those defined?
Hi guys, anyone knows where are the get / put method you use in functional controllers test defined? I mean, grep cannot find them :-( I basically need the documentation for put. Thanks Duncan -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060123/810be962/attachment.html
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
2008 Nov 11
1
Admin controller
This is very weird behavior for rails. 1. When I visit my app http://localhost:3000/admin/base/login class Admin::BaseController < ApplicationController def login render :text => "running" end end 2. but when I go here http://localhost:3000/ I get error because login.html.erb not found 3. even though my route looks like this. map.root :controller =>