Displaying 20 results from an estimated 5000 matches similar to: "Error in validation"
2008 Jan 02
6
problem when editing record in polymorphic relation
I have the following three models created applying the polymorphic
concept
==========================================================================
class SoftwareCi < ActiveRecord::Base
has_one :ci, :as => :content
end
class HardwareCi < ActiveRecord::Base
has_one :ci, :as => :content
end
class Ci < ActiveRecord::Base
belongs_to :content, :polymorphic => true
end
The
2006 Feb 10
1
Bizarre ActiveRecord::Errors/validation problem
I could be going mad and missing something really obvious here but I''m
getting an unexpected result from the following.
The schema:
create_table :services, :force => true do |t|
t.column :id, :primary_key
t.column :name, :string, :ilmit => 5, :null => false
t.column :port, :integer, :null => false
t.column :status, :string
end
The model:
class Service <
2012 Nov 17
2
Help needed for error in foreign key validation
I have two models bank and country. User should only associate a Bank with
a country id present in the country table and I put validates presence of
country to enforce it but i get error mysql2::Error: Unknown column
''countries.bank_id'' in ''where clause'': SELECT `countries`.* FROM
`countries` WHERE `countries`.`bank_id` = 17 LIMIT 1 when updating the bank
2007 May 14
0
building and saving has_many and has_one relations
Hi,
I am very confused about an aspect of has_one and has_many relations,
with regard to using the build method, and saving the belongs_to side.
It''s a somewhat long post. so please bear with me :)
First let''s consider the has_one scenario. Let''s say I have a student
who must own exactly one car:
class Student
has_one(:car)
end
class Car
belongs_to(:student)
2006 Jul 29
3
Validating two models
Hi,
I have a model Account wich "has_one" model called UserData. Both models
use validation.
# Model contains user name, email etc.
class Account < ActiveRecord::Base
has_one :user_data, :foreign_key => "user_id"
validates_presence_of :email
end
# Model contains firstname, lastname etc.
class UserData < ActiveRecord::Base
2009 Jul 07
1
Adding data in two tables simul;taneously with Validations
Hi All,
I have 2 tables
1] user_infos &
2] users
class UserInfo
has_one :user
validates_presence_of :city
class User
belongs_to :user_info
validates_presence_of :first_name
i write following code in my create method.
@user_info = UserInfo.new(params[:user_info])
@user=@user_info.build_user(:first_name=>'''')
if @user_info.save
else
end
now what i want is to
2008 Sep 29
1
has_one :through with :source. How to alias association?
Hi to everyone,
I have the following models:
class Attachment < ActiveRecord::Base
has_attachment :content_type => [:image, ''application/pdf''],
:max_size => 3.megabytes,
:path_prefix => ''../private/attachments'',
:storage => :file_system,
:processor => :rmagick,
2010 Feb 01
3
validating both sides of a has_one relationship breaks pickle/machinist tests
A lot has been posted about validation issues with associations,
however, I don''t see this issue addressed specifically.
ex:
class Foo
has_one :schedule, :dependent => :destroy
validates_presence_of :schedule
class Schedule
belongs_to :foo
validates_presence_of :foo_id
this creates a circular dependency that breaks test frameworks like
pickle and machinist.
At first I was
2009 May 25
4
after_create and has_one association bug?
Hello,
I''ve come across an issue that I''m sure is a bug when using after_create
with a has_one association, but I''m not 100% certain if I''m missing
something.
This is pretty much exactly the code I''m using. Two simple classes
(Account and Contact) and I create the contact after I create an account
(via after_create). I''m not passing in a
2006 Apr 10
3
Problems with multiple ActiveRecords and Validations
Hi all,
I am a RoR newbie and have the following scenario set up:
There are 2 ActiveRecords involved, the first one being "User", the
second one being "Visibility".
The corresponding users table holds address informations regarding a
User. The visibilities table holds visibility settings for the
individual columns of the users table (i.e. firstname, lastname, country
2005 Oct 12
4
Validating 2 related models at once not working
Hello,
I have a form that submits data to two related models/tables. One is
Customer the other is Address. Validation for Customer works fine but not
for the Address.
Class Customer < ActiveRecord::Base
has_one :address
validates_presence_of :login, :password, :email
validates_associated :address
end
Class Address < ActiveRecord::Base
belongs_to :customer
validates_presence_of
2009 Apr 02
3
error_messages_for does not display the error
Hi all
I''ve approached Rails since a couple of months to develop a quick
application for my company. Fantastic framework. As every noob, I do
have some gaps to cover. The one which is giving me a little
frustration, generated by my lack of knowledge is as follows.
I need to make sure the region object is not deleted if there are
countries associated with it. I solved this by putting a
2007 Jan 23
0
validates_presence_of fields. in parent ok, but how in children?
i have the problem that my child class fileds aren''t validated on
saving the
parent. working with parent and child works without problems.
if all fields are filled correctly everything is saved as expected.
but missing fields in the child arent added to the errors.
following short sample shows what i try:
Model
-----------------------------------------------------
class Parent <
2008 Jun 29
2
How to write test about validates_associated
Here is my model:
class Account < ActiveRecord::Base
has_many :users, :dependent => :destroy
has_many :bus
belongs_to :currency
has_many :mylogs, :dependent => :destroy
has_many :batchuserdefines, :dependent => :destroy
has_many :materialuserdefines, :dependent => :destroy
has_many :materials
has_many :inventories
has_many :batchs
has_many :courses
has_many
2006 Jul 19
1
Updating a model from a checkbox (noob question)
Hello everyone,
I''m trying to wire a combobox in a view to update the database. When I
select something in the combobox and press ''update'' it goes through
fine, except it places the default value for the field of the combobox.
Any suggestions?
Here''s the model:
class TestResult < ActiveRecord::Base
has_one :status_index
has_one :test_type
has_one
2006 Apr 07
1
Validate_presence_of error in nested object is not displayed
Hi,
I have a contact object . This contact has a address object
>>Contact
class Contact < ActiveRecord::Base
has_one :address
validates_presence_of :first_name ,:last_name
end
.>>> Address
class Address < ActiveRecord::Base
belongs_to :contact
validates_presence_of :address
end
Addres has the following fields ; address, phone, fax, email
In the contacts_controller I
2008 Jul 22
2
ActiveRecord Associations issue
Hello all and thank you for reading this message.
I am new to RoR, and ruby too, but i am quite excited about it.
I am developing a RoR project and with active record associations in
the following
manner
# Tables (all tables have only one record)
CREATE TABLE `webcars_development`.`cars` (
`id` int(11) NOT NULL auto_increment,
`model_id` int(11) NOT NULL default ''0'',
2012 Aug 17
3
Rails doesn't validate create_model or build_model (has_one association)
I''ve got User has_one Shop. Rails is not validating when I tried
create_shop or build_shop, neither in the browser nor the rails console.
My code:
class Shop < ActiveRecord::Base
attr_protected :user_id
belongs_to :user
validates_presence_of :name, :primary_address, :city, :country_code,
:currency
end
class ShopsController < ApplicationController
before_filter
2006 Aug 09
0
association dows not grt foreign key
I have a 1 to 1 relationship using a similar example as below
(has_one, belongs_to)
but when I do the save, the foreign key of the child object is not set
to the id of the parent object in the relation ship
any ideas?
cheers
dion
---------------------------------
class Person < ActiveRecord::Base
has_one :address
validates_presence_of :email
---------------------------------
end
2006 Aug 09
0
Re: association does not get foreign key
On 8/10/06, Dion Hewson <dionhewson@gmail.com> wrote:
>
> I have a 1 to 1 relationship using a similar example as below (has_one, belongs_to)
>
> but when I do the save, the foreign key of the child object is not set to the id of the parent object in the relation ship
>
>
> any ideas?
>
> cheers
>
> dion
>
> ---------------------------------
>
>