similar to: accepts_nested_attributes_for with has_many => :through

Displaying 20 results from an estimated 900 matches similar to: "accepts_nested_attributes_for with has_many => :through"

2011 Sep 27
0
accepts_nested_attributes_for is not working for uniqueness
class User < ActiveRecord::Base accepts_nested_attributes_for :emails, :allow_destroy => true, :reject_if => proc { |attributes| attributes[''address''].blank? } end class Email < ActiveRecord::Base belongs_to :user validates_presence_of :address validates_email_format_of :address validates_uniqueness_of :address,
2009 Jun 24
1
accepts_nested_attributes_for :reject_if issue
I have the following models: class Order < ActiveRecord::Base belongs_to :billing_address belongs_to :shipping_address accepts_nested_attributes_for :billing_address accepts_nested_attributes_for :shipping_address, :reject_if => proc { |attributes| attributes[''has_shipping_address''] != ''1'' } def after_initialize self.build_billing_address
2011 Feb 11
1
accept_nested_attributes, reject_if doesn't work.
class Post < ActiveRecord::Base validates :name, :presence => true validates :title, :presence => true, :length => { :minimum => 5 } has_many :comments, :dependent => :destroy has_many :tags accepts_nested_attributes_for :tags, :allow_destroy => :true, :reject_if => proc { |attrs| attrs.all? { |k, v| v.blank? or v.nil? } } end rails c
2011 Feb 08
0
Sorting by inner has_many through attribute
Hello everyone, For this model: class User < ActiveRecord::Base has_many :component_users, :dependent => :destroy has_many :components, :through => :component_users, :conditions => [''components.active = ?'',true] accepts_nested_attributes_for :component_users, :reject_if => lambda { |a| a[:components].blank? || a[:components] [:name].blank? },
2013 Mar 30
1
How to use group in nested associations
The below query fails: Timesheet.joins(:time_entries).select("timesheets.*, sum(time_entries.worktime) as total").group("timesheets.start_date") The models have the following relations: Timesheet < AR has_many :activities, dependent: :destroy, inverse_of: :timesheet has_many :time_entries, through: :activities accepts_nested_attributes_for :activities,
2013 Mar 14
0
[Rails 3.2] accepts_nested_attributes_for and time_select
Hi, I am upgrading a Rails application from Rails 3.1.11 to 3.2.12, but have a problem with ` accepts_nested_attributes_for` in conjunction with multipart attributes. The app is used to manage oral exams, so there is a model `Exam`, which has many `Examdate`s. When creating an exam, I can also create the examdates, consisting of a date, a start time and an end time. While the date field is
2011 Jul 16
0
nested_form gem don't work for accepts_nested_attributes_for :limit
Hello, I have the next: class Post < ActiveRecord::Base has_many :image, :dependent => :destroy accepts_nested_attributes_for :image, :allow_destroy => true, :limit => 4 end class Image < ActiveRecord::Base belongs_to :Post ... paperclip settings ... end And the form view for the post is: <%= nested_form_for @post, :html => { :multipart => true } do |f| %>
2013 Mar 25
1
validates presence of foreign key fails in nested form
I''m using accepts_nested_attributes as follows: class Timesheet < ActiveRecord::Base attr_accessible :status, :user_id, :start_date, :end_date, :activities_attributes has_many :activities, dependent: :destroy has_many :time_entries, through: :activities accepts_nested_attributes_for :activities, allow_destroy: true end class Activity < ActiveRecord::Base attr_accessible
2009 Apr 12
0
rails 2.3 nested forms with has_many through checkboxes
I was wondering if anyone knew of a way to combine the new nested forms in rails 2.3 with a has_many through relationship via checkboxes. Basically I have a page model, a page_category model and a category_items join table. Pages have many page categories through category items. The category_items table is polymorphic so i can use it for other models who need categories (maybe this is
2010 Jan 07
1
text field with autocomplete
Hey everybody, I am using text field with autocomplete in my posts new action. That works great. Response from autocompleter in firebug: POST http://localhost:3001/posts/auto_complete_for_tag_name 200 OK 68ms but if I use the same in edit action it fails and I got this error. POST http://localhost:3001/posts/781/auto_complete_for_tag_name 404 Not Found 81ms *** POSTS controller: *** def
2008 Dec 10
3
rspecing rjs - form.reset(''form'')
Hello, > > I couldn''t find much info on this. > > How do you rspec this: page.form.reset("form") > > I looked in the have_rjs source code and I can''t find anything on form > reset. > > Thanks, > > -- > Andrei > -------------- next part -------------- An HTML attachment was scrubbed... URL:
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
2012 Aug 13
10
Question about PATCH method, accepts_nested_attributes_for, and updates to association lists (has_many, HABTM)
Am interested in the new PATCH method that will be included in Rails 4, but have a question/concern, and forgive me if I''m misunderstanding it. So, if the request parameter _method is set to "patch", the update is processed as a patch. But, let''s say you have a model called Airplane and Airplane has a collection of FlightCrewMembers which it
2010 Jan 26
2
accepts_nested_attributes_for :has_many :through => 'bug?'
Hey guys & ladies! I''ve got the following relationship which i''m trying to get accepts_nested_attributes to work with. But when i submit my form, it looks as if its expecting a Company object, rather than an array of companies. which really doesn''t make sense considering its a has_many :relationship. So what i''m after, is a way to
2009 Nov 06
0
Nested objects not propagating from view
I thought I had this fixed, but apparently not. It works okay from the console, but not from the view. I have the following: # partial schema create_table "users", :force => true do |t| t.string "login", :null => false t.string "first_name" t.string "last_name" t.string "email", :null => false
2006 Mar 31
4
javascript help
Hi list, I have a list of tags. I want to be able to click on a tag and have that tag name populate an input field. I think delicious used to allow you to click on existing links to tag your bookmark similar to this (moving instead to auto_complete). My guess is the code looks something like this.... <form> <input type="text" name="all" id="discover"
2010 Mar 01
3
has_many models in a form
Hi, guys. There are four models in the program, A has_many B through C, B has_many A through C, A has_many D, D belongs_to A. I have a form to create A. Inspired by Ryan Bates'' railscasts I was able to create A and D in the same form, and link A to B(created beforehand) through C in the same form as well. Is it possible to create A and B in the same form? Thanks in advance. -- Posted
2013 Jul 21
4
how to use activemodel collection.build for a has_many :through association
Hi all, In my controller I am doing the following to populate a nested form for a has_many through association: def new @specification = Specification.new Component.find_each.each do |component| @specification.component_specifications.build(:component_id => component.id) end The idea being whenever someone creates or edits a form, it will be populated with all
2010 Dec 09
2
Skip validation on nested attribute
Hi, I have a two models, advert and address. An advert has one address. On my advert form I have a nested form of the address. But I only want to create the nested address depending on the adver kind. how can I skip the nested attribute validation? -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails:
2010 Feb 25
1
accepts_nested_attributes_for vs. multiple controllers on one page
Hi, I''d like to render the results from show, create, edit and delete actions for several different models (one controller per model) on one page. While these several models are conceptually related, they do not need to be associated with each other. So, I''d rather not impose associations on them just to use accepts_nested_attributes_for to facilitate their presentation in a