Displaying 20 results from an estimated 1000 matches similar to: "Allow blank on should validate_uniqueness_of"
2007 Nov 25
5
Can't find rails after re-installing/upgrading Kubuntu
Hello Railers (?),
I have just re-installed my machine with the lattest Kubuntu, which brings with Rails 1.2.4 instead of 1.2.3. Now my Rail project doesn''t start anymore. At first I''ve got this message:
Cannot find gem for Rails ~>1.2.3.0:
Install the missing gem with ''gem install -v=1.2.3 rails'', or
change environment.rb to define
2007 Sep 30
2
Outputing to the browser, how?
Hello,
I''m writting some helper methods to write forms, so I have this working code:
class TableFormBuilder < ActionView::Helpers::FormBuilder
["file_field", "password_field", "text_field"].each do |name|
define_method(name) do |label, *args|
@template.content_tag(:tr,
@template.content_tag(:td,
@template.content_tag(:label,
2010 Jun 11
5
Issues creating tables in mysql tests
Hello,
I''m a beginner, so any hints are appreciated; I''m still trying to find my
way around Rails code. For a bug I''ve found I need to create a table called
"values" so I added this:
create_table :values do |t|
t.integer :value
end
among the other table creations in
activerecord/test/cases/migration_test.rb. Is that ok? But then, when I run
the tests
2009 Nov 09
3
How can I improve a Ruby on Rails code that hast a lot of SQL as strings?
Hello Railists,
I have a piece of Ruby on Rails code that has a complex SQL query (well, not
that complex, but as far as I know beyond the ORM capabilities) and for my
taste it has too many strings and harcoded values. I''d like to improve it as
much as possible, so my question is open ended, what else can I do to
improve it?
Some particular issues I have
- Is there a way to get a table
2006 Mar 26
9
validate_uniqueness_of {combination of fields} ???
I''ve looked at the validates documentation and it appears that validates_uniqueness_of works on only one field at a time. So I can, for example, validate that "sam" is unique to the record set, and that "smith" is unique to the record set.
My problem is that each record includes two fields, the _combination_ of which must be unique to the record set, but each of
2011 Aug 22
6
Trouble with Ruby on Rails
Some background info: I am an OS X user, and my MAC system is OS X
10.6.8(snow leopard).
@1st problem (regarding Ruby on Rails installation):
I have installed ruby "1.9.2" with RVM. When I typed "ruby -v" command
in terminal after installation, it says that the ruby version I have
is "1.8.7". Strange, isn''t it? So, I have tried "rvm use 1.9.2"
2010 Jul 24
23
How to disable ORM in Rails 3
Is there any way to prevent Rails 3 from using an ORM? In Rails 2, it
used to have a description in environments.rb explaining how to do that.
In Rails 3, is there any way to tell it to not use any database? I was
trying to make some benchmarks from situations that don''t require a
database...
Thanks in advance,
Rodrigo.
--
You received this message because you are subscribed to
2010 Jun 21
9
[BUG] Segmentation fault
First of all, I use RVM and I installed ruby-1.9.2-head, which I used
to create a new rails3 gemset. Then I changed to that gemset with rvm
use 1.9.2-head@rails3 and I ran bundle install over the following
Gemfile:
source ''http://rubygems.org''
gem ''rails'', ''3.0.0.beta4''
gem ''sqlite3-ruby'', :require =>
2005 Dec 14
0
validate_uniqueness_of builds queries with IS NULL when value is nil (since RC 5)
Hi people,
Ever since RC 5 (including 1.0) my unit tests that test for inserting
duplicate entries fail and throw errors. Each of them implements
validate_uniqueness_of to prevent duplicates. While I also put in a
ticket for this, I''m wondering if this is actually a defect or maybe
intended behaviour afterall. If so, I won''t apply the patch again and
look for another
2008 Mar 18
0
Case sensitive validate_uniqueness_of isn't working
Hi,
validate_uniqueness_of has the option :case_sensitive, this option is
true by default, there are tests to check that :case_sensitive =>
false is working, but there isn''t any test to check that, when set to
true (the default!), is working, in fact it doesn''t work at.
There isn''t a database agnostic way to do a case sensitive search,
there is in myql (binary like)
2009 Sep 08
1
How to validate_uniqueness_of the joint of two attributes?
Hi,
I have a form that asks users to put in their :first_name and :last_name.
How do I validate that their full_name (first_name + last_name) is unique?
Thanks!
Nguyen Anh Hung
Assistant Project Manager/ Consultant/ Business Analyst
Tech Propulsion Labs
Mobile: +84987 005 477
Twitter: http://www.twitter.com/anhhung
Blog: http://www.fresco20.com
Skype: anhhung.n | Yahoo: hero.tuxer | Gtalk:
2011 Jun 19
10
validates_numercality_of with allow_nil.
In the model I have:
validates :square_meters_public_land, :barrier_meters, :numericality
=> { :greater_than_or_equal_to => 0 }, :allow_nil => true
but if, in the field, on create, I don''t insert a value I have the
error "field is not a number".
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To
2007 Dec 27
4
validates_file_format_of only when is there an image
i have a model with this:
file_column :image
validates_file_format_of :image, :in => ["gif", "png", "jpg"]
If inthe form the user not insert the image i receive an error.
If i remove:
validates_file_format_of :image, :in => ["gif", "png", "jpg"]
it works.
Is possible do the validation only when user insert the image in form?
i
2013 Apr 03
1
validates uniqueness scope allow_blank/allow_nil -> validation error
I have this in a model:
class GenreBadge < ActiveRecord::Base
belongs_to :game, counter_cache: :genre_badges_count, touch: true
belongs_to :genre
validates :game_id, uniqueness: {scope: :genre_id}, allow_blank:
true
end
When I get one existing genre badge
genre_badge = game.genre_badges.first
genre_badge.game_id = nil
genre_badge.save!
It creates an validation exception:
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 Nov 21
2
keeping dim() for array
Hi All,
I noticed the following:
pip = array(1:6, dim = c(3,2))
dim(pip)
[1] 3 2
pup = pip[1,]
dim(pup)
NULL
I bet there is a *good* reason why one row of an array is *dimensionless*, but
it's highly inconvenient for my purpose, i.e. to use apply() after an array goes
through a number of logical steps and is redimensioned, sometimes to one single row.
How do I keep dim(pup) to 1 2?
2010 Aug 11
6
rspec2 not working with shoulda
I am using rails edge. I am using gem "rspec-rails", "= 2.0.0.beta.
19" .
I have following code at spec/models/user_spec.rb
require ''spec_helper''
describe User do
it { should validate_presence_of(:email) }
it { should validate_presence_of(:name) }
end
Here is my gemfile
group :development, :test do
gem ''factory_girl_rails'',
2010 Dec 22
8
Shoulda issue: no more "should have_instance_methods" ?
I''m using Shoulda.
After copying the code here....
.... http://joshuaclayton.github.com/code/2009/07/14/should-act-as-list.html....
into my test_helper file so I can test acts_as_list, I came across
issues. For one I realized I had to get rid of the _ between the
"should" and "have" in past cases, but here, I get this error when I
run my unit test:
2010 Feb 10
6
validation problems
Hi, there.
I have two validations in the model:
validates_numericality_of :value, :only_integer=>true,
:allow_blank=>true
validates_size_of :value, :is=>9, :message=>"must be 5-digit number",
:if=>Proc.new{|u| u.value.is_a?(Numeric)}
They work as expected except when the :value is character/string like
"a" "abc", the second validation will also output
2009 Jun 07
6
Missing Template when testing with the Brain Buster Captcha partial
When I run my functional tests, they throw an error with the following
message:
ActionView::TemplateError: Missing template /_captcha.erb in view path
app/views:test/vendor/plugins/brain_buster/views/brain_busters
On line #23 of app/views/contacts/_form.html.erb
20: <%= f.label :message %><br />
21: <%= f.text_area :message %>
22: