Displaying 4 results from an estimated 4 matches for "nested_attributes".
2009 Jun 20
0
[Rails 2.3] nested_attributes and validation of nested model
...y name: </label><%= ao.text_field :name %></li>
<li><label>Address: </label><%= ao.text_field :address %></li>
<% end %>
<% end %>
Both models: User and AgencyOwner:
class User < ActiveRecord::Base
has_one :agency_owner
accepts_nested_attributes_for :agency_owner
validates_associated :agency_owner
# - validation here - #
end
class AgencyOwner < ActiveRecord::Base
belongs_to :user, :class_name => "User", :foreign_key => "user_id"
# - validation here - #
end
Controller:
def add_owner
@user = User.new(...
2013 Feb 27
0
Exended modules and reject_if in nested_attributes
I have some common class methods in a module ''active_record_additions''
that I load into a class by Activity by using extend ActiveRecordAdditions
The Activity class uses nested_attributes_for with a reject_if method saved
in the module ''active_record_additions''
The problem is that the class methods in ''active_record_additions'' works
when I use them as ordinary class methods, but not as a a method in
reject_if.
I got the message NameError (unde...
2013 Feb 10
0
Nested attributes doesnt get updated
...t;=>{
"description"=>"d",
"_destroy"=>"false",
"id"=>"5000000015"}}},
"commit"=>"Update A w request",
"id"=>"5000000022"}
*Stack trace:
*activerecord (3.1.3) lib/active_record/nested_attributes.rb:461:in `raise_nested_attributes_record_not_found''
activerecord (3.1.3) lib/active_record/nested_attributes.rb:426:in `block in assign_nested_attributes_for_collection_association''
activerecord (3.1.3) lib/active_record/nested_attributes.rb:399:in `each''
activerecord (3...
2011 Mar 01
6
render :collection calling partial with phantom object?
I have two models with a straightforward has_many / belongs_to
relationship:
class Premise < ActiveRecord::Base
has_many :metered_services, :dependent => :destroy
...
end
class MeteredService < ActiveRecord::Base
belongs_to :premise
...
end
and nested routes to match:
Demo::Application.routes.draw do
devise_for :users
resources :premises do
resources :metered_services