Displaying 20 results from an estimated 3000 matches similar to: "Why are has_one objects resaved when the parent is saved?"
2006 Jul 04
4
ROaR: A Ruby on Rails Podcast
I''m starting a new podcast to cover some of the hot topics going on in
Rails. Half news, half interactive, all community. As always, the
first episode kinda sucks but I''m looking forward to feedback from all
of you on how to make it better.
http://www.simiancodex.com/roar/
or for iTunes people
http://phobos.apple.com/WebObjects/MZStore.woa/wa/viewPodcast?id=163609703
Michael
2006 Jun 27
2
Patch submission question.
DHH asked for more documentation. Are those patches submitted
indivdually per method or per module documented? Or are they
submitted as some giant patch?
Michael Genereux
SimianCodex
2006 Mar 03
6
has_one :next - invalid name?
I have this in a model:
has_one :next,
:class_name=>''WorkPart'',
:foreign_key=>''next_id''
And it causes this error:
compile error
/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.13.1/lib/active_record/deprecated_associations.rb:83:
void value expression
2006 May 19
5
How to determine if an object has just been created
Is there a built-in way to determine if a model object has just been
created (ie. this object was the one that was originally persisted)? I
can''t see it anywhere in the AR code, but thought I''d check. I want
something like:
p = Person.create
p.original_instance? # true
Is this built-in or should I just patch AR?
-Jonathan.
2006 Mar 19
2
Multiple polymorphic belongs_to declarations
I have the following models:
class Card < ActiveRecord::Base
belongs_to :deck
belongs_to :front, :polymorphic => true
belongs_to :back, :polymorphic => true
end
class TextContent < ActiveRecord::Base
has_one :card, :as => :front
has_one :card, :as => :back
end
The conflicting has_one declarations don''t work. What I need is
2006 Oct 13
3
Validation errors in has_one/belongs_to relationships.
I have two objects, QuoteInput and Insured.
QuoteInput has one Insured and Insured belongs to QuoteInput.
I don''t understand what I''m seeing.
I assign an Insured to a QuoteInput. The Insured object has invalid
data.
I call save! on the quote input. QuoteInput has no validations.
I expect two things to happen - 1) an exception should be thrown,
indicating that there was a
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 Oct 11
3
Basic Relationship Problem
I''m trying to do a basic relationship and it''s not working the way it
should. The data model is obviously a test database as the fields are
minimal.
In irb I do the following:
>> user = User.create(:name => "shawn")
=> #<User:0x259ceac @errors=#<ActiveRecord::Errors:0x259c3a8
@errors={}, @base=#<User:0x259ceac ...>>,
2006 May 08
6
how to make field in model immutable after create
Hello everyone!
I want to have login field in User model which is set only once (on
create), and then it should fail validation if the value is changed.
How can I do this? I dig around for validation and tried
def after_validation_on_update
unless User.find_by_login(:login)
errors.add(:login, "is immutable. You can''t change it")
end
end
in model, but somewhat it
2006 Jan 10
8
Noob: Child records not saved
Hi all,
happily coding along, but it seems a belongs_to record is not saved.
# Create some stuff
def create_project
@contact = Contact.new
@project = Project.new(@params[''project''])
@project_contact = ProjectContact.new(@params[''collect''])
@project.project_contact = @project_contact
contact =
2007 May 22
3
Comments wanted about spec''ing out a couple controller methods
(oops, accidentally sent this to the rspec-devel list, sorry about that)
Could someone help me spec out these Rails controller methods? I
don''t know where to get started, especially with the transaction
stuff. Or, if anyone else could suggest ways I could improve the
code, that would be great as well.
Puzzle has_one Media. Both are AR model objects.
class PuzzlesController <
2006 Apr 24
4
[TIP] Ensure your test data is valid
Recently I wanted to check that my test data was valid. Seems like a
reasonable thing to want to do so I thought I''d share the rake task. Add
this code to a rake file in lib/tasks and run with rake
db:fixtures:validate. It will print out the class, record id and error
messages for any model objects that fail validation.
Enjoy!
-Jonathan.
--
namespace :db do
namespace :fixtures do
2008 Feb 18
5
uh... fixtures?
RSpec-ers:
I''m aware this is quite the FAQ. I have probably asked it myself, but I just
can''t Google up anything but others asking it.
I grabbed the source to Beast, to use as a Rails project uninfluenced by me, or
RSpec. Then I installed the CURRENT version of RSpec and rspec_on_rails, and set
up a model spec on Post.
Here''s the spec_helper.rb lines:
2006 Aug 06
0
Rails Core Weekly July 16 - August 6
Rails Core Weekly July 16 - August 6
Rails Core Weekly summarizes the rails-core mailing list, a list
dedicated to Ruby on Rails internals and its development. RCW is
brought to you by Rodney Ramdas and proofread by the good people of
The Caboose (http://blog.caboo.se/) for accuracy.
RSS feed and RCW home:
http://www.pinupgeek.com/articles/category/rails-core-weekly-news
The ruby on rails
2013 May 02
1
function gstat r with pyhton
? stato filtrato un testo allegato il cui set di caratteri non era
indicato...
Nome: non disponibile
URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20130502/8bc15613/attachment.pl>
2007 Oct 23
11
validates_confirmation_of not working?
I just can''t get validates_confirmation_of working for the life of
me!...
It''s not the first time I''m having problems with it but I just never
understand why!... This time I pretty much followed *exactly* the
example in Agile Rails Development and still...it just won''t work! I put
2 different passwords in the form and it doesn''t trigger an error,
2006 Feb 17
3
Using :include with has_one vs. has_many
While I''m happy to continue talking about the vagaries of Rails deployments, I
also need to actually build apps. :)
I may have discovered a bit of a problem with :include as it applies to has_one
associations. First, let me say that I''m a big fan of :include for reducing the
number of SQL calls. There are times when I wish it could go more than 1 step
away from the parent
2006 Apr 09
4
Inheritance via Though Associations?
I posted something about this a week ago wihtout response, but have made some
progress since. However, I''m still not getting exactly what I want.
OK, three core tables:
create_table :reference_items do |t|
t.column :title, :string, :limit => 255
t.column :year, :integer, :limit => 4
t.column :type, :string
t.column
2006 May 12
1
can I fake has_one :through?
I''m having a difficult time wrapping my head around a set of models
and their associations and seeing how they map into Rails. I''ll try
to lay out my problem using the has_many and belongs_to structures. I
have a RuleSpace, a Rule, and a Subject.
A RuleSpace has_many Rules
A RulesSpace has_many Subjects through Rules
A Rule belongs_to (many) RuleSpaces
A Rule has_many
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