similar to: Explanation of how Scope works?

Displaying 20 results from an estimated 8000 matches similar to: "Explanation of how Scope works?"

2006 Jun 05
2
When adding a record in console, a parameter comes in as null even when I set it
In console, I am trying to create a User but the :account_id does not come in. Console just gives me back :account_id => nil. Obviously I''m trying to set it though. Silly console... But, I can set the account_id column in my controller like so: @user = User.new(params[:user]) @user.account_id = account.id @user.save Here''s what I give to the controller: User.create :name
2008 May 20
5
How to write a test for validates_uniqueness_of
Hi, I have a spec it "should have a unique username " I have a code: validates_uniqueness_of :user_name Now, I don''t know how to test this code. In order to test this, do I need to run `save`? For example, @user = User.create(:username => "mike") @another = User.create(:username => "mike") @another.save.should be_false This messes up test
2007 May 28
5
validates_uniqueness_of does not pass unit test
I am doing some very very basic unit testing. If I take away the uniqueness validation, the tests pass. Could this be a bug in Edge Rails? --~--~---------~--~----~------------~-------~--~----~ 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
2007 Jan 03
2
error_message_on broken?
Hi, in my app, using the error_message_on form helper like this: <label for="user_name">User name:</label> <%= error_message_on ''user'', :name %> <%= f.text_field :name %> generates the following error: undefined method `errors'' for :user:Symbol I am using edge revision 5813 and the simply_helpful plugin. Is there a way to fix this?
2006 Dec 06
2
validates_uniqueness_of where scope euqals created_by "magic" field
I have the following ActiveRecord objects: class Recipe < ActiveRecord::Base has_many :ratings, :dependent => true . . . end class Rating < ActiveRecord::Base validates_uniqueness_of :created_by, :scope => :recipe_id belongs_to :recipe, :counter_cache => true . . . end The created_by field on Rating is implemented as a "magic" field similar to this:
2006 Nov 29
2
validates_uniqueness w scope
In a one-to-many relationship (domain has_many :categories and category belongs_to :domain) In the category model I use: validates_uniqueness_of :name, :case_sensitive => false but upon creation of a category this validation is performed on ALL domains, can I restrict it only to the categories of the current domain, the to which teh category being saved belongs_to ? if yes ? how ? thanks
2007 May 06
1
validates_uniqueness_of (with :scope) doesn't seem to work?
I have a master record called ''project'' and a child record called ''agycode''. Obviously, agycode has a project_id FK. I wish to make the "descr" field unique ONLY within the ''project_id'' ''scope''. Here are the key pieces of information Agycode fields (id, project_id, descr) Here''s the declaration in the
2006 May 10
7
has_many :through scope on join attribute
Hi I have a has_many :through. It''s a basic mapping of Project id .... User id .... TeamMembers project_id user_id role What I would like to do is have different roles so I can have in the project model has_many :core_members, :through => :team_members, :source => :user but I would like to limit this to only those with the "core" role in the team members table for
2006 Jun 19
3
Using set_primary_key breaks acts_as_tree with non-integer column
I just switched from using the standard "id" column into using my own primary key and generating my own unique id for each record. But, this breaks acts_as_tree. Because my new primary key is not an integer, it breaks the SQL query as follows: StatementInvalid in PagesController#create --------------------------------------------------------------------------------------
2012 Nov 08
1
validates_uniqueness_of(*attr_names) w scope not working in unit test
Rails 3.2.8 Very strange , it works in dv mode console , but not in a unit test class User < ActiveRecord::Base belongs_to :subdomain validates_uniqueness_of :email, :scope => :subdomain_id class UserTest < ActiveSupport::TestCase def initialize_user @booboo = FactoryGirl.create(:subdomain, name: "booboo") @coocoo = FactoryGirl.create(:subdomain, name:
2006 Feb 11
2
validates_uniqueness_of - how to use multiple values for scope
Hi I''m trying to create a basic test management tool to organise the manual testing I have to do. I''m working on the results recording module and have a problem. Basically, I want each test result to belong to a test case, a test environment and a build. I want to make sure there''s no duplication of results with these 3 properties. If someone tries to enter a new test
2006 Jan 11
3
How do you do a custom sql call in rails?
Hi. I am developing an industry specific crm that allows busineses to track customers in a particular way. Each customer will be assigned a customer number. The first customer will have a customer number of 1, the second customer_number = 2, etc... Note that this customer number is not global but particular to the account that created the customer (see schema snip below). I need to have a
2014 Dec 31
1
Authenticating Virtual Users without domain
Hi, I'm trying to migrate a large number of users to a new Dovecot cluster. The existing mail system allows a user to authenticate with a bare username if they have connected to the correct local IP on the server. e.g. imap.somedomain.com = 1.1.1.1 imap.anotheromain.com = 2.2.2.2 charlie at somedomain can authnenticate as 'charlie' or 'charlie at somedomain.com' as long as
2005 Oct 03
3
WriteBoard for Programmers? (code support)
Anyone think it''d be useful to make a WriteBoard type application that supported ruby, html, etc. and allowed programmers to collaborate on writing scripts or just code in general and track each others changes? Just a thought. - Jim
2006 Mar 09
2
issuing raw SQL in Rails
Hi -- I have a need to run the following SQL in a test: "DELETE FROM agents_bookings" Does anyone know of a way that I can just execute this? It is to clear a many-to-many relationship in the teardown function of a test. Cheers, doug. -- Posted via http://www.ruby-forum.com/.
2008 Nov 12
5
dynamic condition for has_one and eager loading issue
Hi, I ve defined the following relation in one of my models with a dynamic where condition: has_one :selection, :foreign_key => ''object_id'', :conditions => ''selection_type = 1 and account_id = # {self.send(:account_id)}'' That works perfect, however when I try to eager load that relation I am getting the following error when doing a
2006 Apr 03
11
Runaway FCGI Processes with Debian, Apache
Hi all. There is an issue with Rails, FastCGI and Apache2 on Debian that I''ve been dealing with since I started Rails development in late 2005. I''ve developed various workarounds but have not been able to solve the problem at the root. Every so often, for reasons I''ve never been able to determine, a load of dispatch.fcgi processes get spawned and take over my whole
2009 Nov 27
2
update_attribute does not update
My server is running Rails 2.3.4...am I not doing this correctly or is something borked? >> c=Contact.last => #<Contact id: 24, name: "Larry", email: "larry-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org", phone: 2147483647, account_id: 8, created_at: "2009-11-27 18:16:25", updated_at: "2009-11-27 18:40:08", hide_name: false, hide_phone: false,
2010 Dec 02
8
CanCan issue when being very specific
So I got CanCan and Devise working well. I have two types of users: Admins and Nonadmins. Admins can edit all of Nonadmins profiles. The problem is, every user (either Admin or Nonadmin) belongs to an Account or Organization. Admins should only be able to edit users from their own Account or Organization. I was able to do that too. The problem is, I can''t display the Create New User
2006 Jan 19
4
A simple scaffolding question
All, When I generate scaffolding on my model, it doesn''t display all the fields in the create and edit views. It populates the views with text/char and date types, but omits any integer fields. Is this normal behavior or a bug? Thanks! -Nick