Displaying 20 results from an estimated 30000 matches similar to: "validates_uniqueness_of and attr_readonly"
2009 Jul 02
1
Prevent attribute from being changed with "attr_readonly"
Is there a way to prevent an attribute from being changed from outside
the class instance? So that after a record is created, the attribute can
be read but cannot be changed from outside the class instance.
At first glance, "attr_readonly" seems to be the solution. However,
will "attr_readonly" also prevent the attribute from being changed even
from inside the class?
In
2009 Jun 17
2
validates_uniqueness_of fails on STI in Rails 2.3.2
I''ve got something like this:
class Position < ActiveRecord::Base
end
class CartItem < Position
validates_uniqueness_of :product_id
end
When I try to save CartItem I get this error:
ArgumentError: wrong number of arguments (1 for 2)
from
/home/joaz/.gem/ruby/1.8/gems/activerecord-2.3.2/lib/active_record/validations.rb:758:in
`exists?''
from
2007 Nov 16
1
small patch for attr_readonly
A small patch to fix attr_readonly when used in conjunction with
optimistic locking
Please Review:
http://dev.rubyonrails.org/ticket/10188
+1 if it works for you.
nick.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group.
To post to this group, send email to
2007 Dec 11
2
Build issues on Leopard
Hello,
I''m having some issues building r190 on Leopard (10.5.1):
$ rake
(in /Users/johan/temp/superredcloth)
ragel superredcloth_scan.rl | rlgen-cd -G2 -o superredcloth_scan.c
ragel superredcloth_inline.rl | rlgen-cd -G2 -o superredcloth_inline.c
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby
extconf.rb
checking for main() in -lc... yes
creating Makefile
make
gcc -I.
2009 Jun 15
6
Spork and Merb and rSpec
Andy Shipman wrote:
> When running spork on a merb application, whenever a spec is run I get
> the following error from the Spork server.
>
> /opt/local/lib/ruby/gems/1.8/gems/merb-core-1.0.11/lib/merb-core/bootloader.rb:1358:
> [BUG] rb_gc_mark(): unknown data type 0x3c(0x2203d0) non object
> ruby 1.8.7 (2009-06-08 patchlevel 173) [i686-darwin9]
>
> Which crashes the
2008 Sep 19
0
validates_uniqueness_of: passing a method to :scope
I was wondering if anybody knows an easy way to pass a method name as
the scope option to a validates_uniqueness_of validation on a AR model?
For example, I have nested models a bit like:
class Survey
has_many :areas
end
class Area
belongs_to :survey
has_many :questions, :order => ''position''
validates_uniqueness_of :position, :scope => : survey_id
end
class
2010 Mar 30
0
SystemTimer not installing correctly
Here is the output when I try to install the gem:
Building native extensions. This could take a while...
Successfully installed SystemTimer-1.2
1 gem installed
Installing ri documentation for SystemTimer-1.2...
Updating ri class cache with 6252 classes...
/Users/chabgood/.gem/ruby/1.8/gems/rdoc-2.4.3/lib/rdoc/ri/driver.rb:
818: [BUG] Bus Error
ruby 1.8.7 (2010-01-10 patchlevel 249)
2009 Jul 04
12
save! not allowed after validates_uniqueness
I have this in a model
validates_uniqueness_of :aspect, :scope => :user_id
In an instance method of the same model I have "save!" but I don''t touch
the :aspect attribute in that instance method at all.
Whenever that save! command is run however I get this error:
ActiveRecord::RecordInvalid: Validation failed: Aspect has
already been taken
I don''t
2009 Jun 26
0
validates_uniqueness_of and MySQL enum type
I tried to check validates_uniqueness_of for a MySql enum type column
with a scope given, like this:
validates_uniqueness_of :phone_type, :scope => :user_id
And It didn''t work. When I check the SQL statement for doing this
validation, it is like this:
SELECT `phone_numbers`.id FROM `phone_numbers` WHERE
(`phone_numbers`.`phone_type` = BINARY '''' AND
2009 Oct 02
0
Problems with validates_uniqueness_of
Hi to everybody, well i recently became a RoR developer, web i was
following the video class from Lynda, and i introduce more code in my
aplicacion, my application is a music store web site, ok so i add the
funcionality of add clients, for that i need from my client, his user
and password, so it will be 1 user per client, for that reason i use at
my model
validates_uniqueness_of :user
2006 May 18
1
validates_uniqueness_of
I used validates_uniqueness_of
it is case insensitive, it takes only admin not Admin.
So please help me out how to put validates_uniqueness_of as case
sensitive
Thanks in Advance
Surekha.Matte
--
Posted via http://www.ruby-forum.com/.
2006 Aug 10
2
validates_uniqueness_of problem
hi
Could I check to strings for uniqueness together and not individually?
That means for me in an example:
name: sex: result:
----- ---- -------
miller m unique
miller f unique
jackson m unique
miller m isn''t unique
So I want to check the name and sex be together unique. The name isn''t
2008 Aug 21
1
validates_uniqueness_of not working - urgent
I''m using restful_authentication to let users register and login.
Lately, however, I''m seeing multiple login and emails being created
even though I have validates_uniqueness_of as below:
user.rb
validates_uniqueness_of :login, :email, :case_sensitive => false
mysql> select id, login, email, created_at, state from users;
2006 Apr 27
4
customize validates_uniqueness_of
I need to modify the validates_uniqueness_of function so that it will
check that the string is unique but only in its own category.
For example right now I have
validates_uniqueness_of :title
so let''s say I have the :title "Title 1" already in the database with
the :category of "1"
then if i wanted to enter the :title "Title 1" in the database again BUT
2006 May 10
4
validates_uniqueness_of and create atomicity
Hi folks,
I have a question regarding validates_uniqueness_of, and similar
before-filter-like events attempting to guarantee some DB state prior
to modification.
>From my reading of ActiveRecord, validate_uniqueness_of appears to
cause a SELECT on the underlying table attempting to ensure that a
record with ID(s) specified in the validates_uniqueness_of statement
is not already present, prior
2006 Jul 28
0
Dreamhost, fastcgi, validates_uniqueness_of.... is not always unique?
Hey everyone,
I have an application running on dreamhost with fast cgi (FCGI). I have a
model, "Member", that has the following validation:
validates_uniqueness_of :email, :if =>
Proc.new{|member| !member.email.blank?}
The :if clause is really not needed because an email address is required and
in fact the model also has:
validates_presence_of :email
2005 Oct 29
0
Problem with validates_uniqueness_of
Hi,
I think I''ve found a problem with validates_uniqueness_of within
ActiveRecord.
My code is:
validates_uniqueness_of :name, :on => :create, :scope => "zip", :message
=> "has already been taken"
yet the docs say that when a record is created, a check is performed to
make sure that no records exist in the database with the given value for
the specified
2010 Aug 28
1
validates_uniqueness_of missing in rails 3.0 rc2?
Has anybody noticed validates_uniqueness_of missing in rails 3.0 rc2? I''m not sure if this is a bug or I''m just doing something wrong.
Here''s what I''m doing.
Class 1:
class Title < ActiveRecord::Base
validates_length_of :language, :is => 3
validates_uniqueness_of :language, :scope => :book_id
validate :language,
2013 Jul 17
0
opusfile, compiler warnings
Just a report about compiler warnings generated when building opusfile
from current git. Regards.
# x86-Linux builds / gcc48 and clang-3.3
(no warnings)
# x86-Linux builds / gcc34
src/opusfile.c: In function `op_calc_bitrate':
src/opusfile.c:1777: warning: integer constant is too large for "long" type
src/opusfile.c: In function `op_open2':
src/opusfile.c:1131: warning:
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: