similar to: Accepting build_association parameter for fields_for helper or build association object automatically

Displaying 20 results from an estimated 20000 matches similar to: "Accepting build_association parameter for fields_for helper or build association object automatically"

2012 Sep 21
0
Build belongs_to and has_nor assiciations automanically
I''ve written gem for automatic building associations for fields_for helpers. Please, check it out - https://github.com/ka8725/get_or_build What do you think should it be rails feature? -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to
2010 May 27
4
[PATCH] Rails 3: fields_for helper doesn't work with association proxy objects
Request for eyeballs. :-) Mongoid uses association proxy objects. It overrides #nil? => false when the association is missing. However since it uses proxy objects, !!assocation is always true. I have created a ticket with a patch that changes the association nil test to call assocation.nil? rather than use implicit coercion of the variable. See:
2011 Mar 01
0
Association data within a fields_for
How do I use association data from within a fields_for? I''ve got a has many through relationship between users, schools and schools_users. A user can have multiple schools and a school has multiple users. In schools_users there is a user_role field in addition to the common user_id and school_id. In the show view I have: <% @school.schools_users.each do |user| %>
2010 Dec 07
1
fields_for and one out of many from association
class Person < ActiveRecord::Base has_many :addresses has_one :primary_address, :class_name => ''Address'', :order => ''preferred desc, id'' accepts_nested_attributes_for :addresses, :allow_destroy => true accepts_nested_attributes_for :primary_address, :allow_destroy => true end class Address < ActiveRecord::Base belongs_to :person end
2012 Jul 28
1
`build_association` produces DB-queries
Let `User.has_one :profile`. I''ve always thought that `@user.build_profile` is a cheap thing to do - it''s just creating a new object without persisting it. But, in fact, it does 2 queries to the DB: `BEGIN` and `COMMIT`. In my app I have an admin users#index page where users'' details can be edited, and to simplify the code I build a profile whenever it''s
2009 Oct 15
4
Getting the object in fields_for
I''m using the fields_for helper with accepts_nested_attributes_for The System model has_many children. If I do this in my haml template: -form_for @system do |s| =s.text_field :name -s.fields_for :children do |child_fields| =child_fields.text_field :name all is fine. The fields_for iterates over all children and puts the correct data in the fields. But...what I
2009 Feb 09
2
how to get form parameters while using fields_for with nested attributes
hi all.. i am trying to use *fields_for* to get and save nested attributes in a form. i have a ''Partner'' model associated with an ''Address'' model. partner has_many :addresses although the form is displaying fine, but on submitting it the following error is shown: *can''t convert HashWithIndifferentAccess into Array* on this line: *@partner =
2009 Feb 18
5
fields_for and Conflicting types for parameter containers. Expected an instance of Hash but found an instance of Array.
I''m trying to use ''fields_for'' in a form. I want the same form to support both the creation of new obejcts as well as the editing of old ones. So - in my controller, sometimes I will pass to the form an object that already exists in my database and has an id and other times I will pass it a newly created instance of an object that does not yet exist in the database and
2008 Dec 02
4
Am I wrong or is fields_for not working right in Rails 2.2.2
I may be totally wrong about what the fields_for method is supposed to do, but for some reason I thought using it scoped an object around an association. For example, I have a User class and when you''re creating a new user I want to use fields_for to add a BillingAddress to the user like so: <%- fields_for :billing_address do |billing_address_form| -%> <%= render :partial
2013 Mar 04
0
fields_for with accepts_nested_attributes: how to pass a value to a label
I can''t figure out how to pass a value from the following object build in the controller: class TimesheetsController < AC ... def new @timesheet = current_user.timesheets.new now = Date.today #generating 7 time entries: monday through sunday (now.beginning_of_week..now.end_of_week).step { |date| @timesheet.time_entries.build(:workdate; date) end end ... In the
2006 Jul 31
2
Updating a belongs_to foreign key leaves the old association object available
Perhaps this is intentional, but it seems unlikely: class Person < ActiveRecord::Base belongs_to :school end p = Person.find(:first) p.school # nil p.school_id = School.find_by_name(''High School'').id p.school.name # High School p.school_id = School.find_by_name(''Primary School'').id p.school.name # High School <= Shouldn''t this be Primary
2009 Oct 15
1
fields_for weirdness
I just did a large upgrade to to Rails 2.3.4 and I am trying to make use of the more modern view features. I have a Newsletter object. Newsletter has many Sections. I also have: accepts_nested_attributes_for :sections on the Newsletter object. I have the typical scaffolded new.html.erb with: <% form_for(@newsletter) do |f| %> in there, I am trying to populate the first Section
2006 Aug 14
1
What fields_for really for?
Hello everyone! I have 3 models: === 1 === class Region < ActiveRecord::Base has_many :districts end === 2 === class District < ActiveRecord::Base belongs_to :region has_many :suburbs end === 3 === class Suburb < ActiveRecord::Base belongs_to :district validates_numericality_of :region_id, :only_integer => true end In edit.rhtml for SuburbController I need to specify
2006 May 16
1
fields_for giving undefined method exception
I''m getting an undefined method exception with the fields_for method. I''m following the gem examples. The form_for works but when I add fields_for it breaks. Are there other examples of how this works anywhere? -- Posted via http://www.ruby-forum.com/.
2012 Aug 25
0
accepts_nested_attributes_for and fields_for not working!
I want to be able to create one menu object that has fields_for :brunch, :lunch, and :dinner. The menu object has_many brunches, lunches, and dinners, but each time I "edit", only one brunch, one lunch, and one dinner object are added. I''m using carrierwave to upload brunch_menus, lunch_menus, and dinner_menus (attributes of brunches, lunches, and dinners respectively) as
2011 Apr 04
1
Best way to instanciate an empty address element in many nested fields_for
Hi! I have 3 models, User, Company and Address. Basically, a User belongs to a Company and an Address has one Company (because it can be linked to other models). In a form I want to display a User, its Company and its company Address, with fields_for. The problem is when my User has a Company, that does *not* have an Address: the part containing the Address is not displayed. I see 2 ways of
2008 Mar 11
1
fields_for in a form_for_remote?
Can you nest fields_for in a form_for_remote? -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to
2011 May 03
0
Simple_Form and Simple_Fields_For and working in Form_Tag, Fields_For
I have this form and i got it working as i want: <%= form_tag(update_individual_photos_path, :method => "put") do %> <%= fields_for "photos[]", @photo do |f| %> ................. <% end -%> <%= submit_tag("Post") %> <% end %> But i would like to move to doing this with simple_form_for and simple_fields_for but i cant get it
2007 Nov 14
0
Problem time_select with fields_for
Hi, I''m using fields_for and a time_select but he isn''t saving the time in the db just 00:00:00 All the other fields are fine, but the time_field isn''t working:s This is my code: <% form_for :activity, @activity,:url => {:action => "create"} do |activity_form| %> <td><%= activity_form.time_select :datum_1_twrak_van, :order =>[ :hour,
2010 Nov 28
6
has_one accepts_nested_attributes_for fields_for NOT WORKING HELP
MODEL class User < ActiveRecord::Base has_one :address, :dependent => :destroy accepts_nested_attributes_for :address end CONTROL def new @user = User.new @user.build_address # Adicionei ... VIEW partial _form .... <% f.fields_for :address do |b| %> # Adicionei <%= b.text_field :city_manual %> # Adicionei <% end %>