search for: fields_for

Displaying 20 results from an estimated 127 matches for "fields_for".

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...
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 |billi...
2009 Oct 15
1
fields_for weirdness
...ures. 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 using fields_for during the newsletter creation. If I try to emphasize "sections" in fields_for , I get an exception. Otherwise, I can do this: <% f.fields_for :section, :index => 0 do |s| %> which in the forms creates newsletter[section][0]. It will recognize :section but not :sections. If...
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 instanciating my empty adress: 1) In the view: f.fields_for :company, @user.company do |company_form| and company_form.fields_for :address, (address = @u...
2011 Jul 25
4
[Rails 3.0.9] I have trouble about fields_for
Hi,all. I''m new bee to Rails and I have trouble about fields_for method.. It isn''t show up between the <%= f.fields ~ <% end %> Please teach me some advice. Thanks! #new/_form.html.erb <%= form_for(@user) do |f| %> <div class="field"> <%= f.label :name %><br /> <%= f.text_field :name %> &lt...
2008 May 02
1
names of select elements inside a fields_for block not generated as expected
...39;' railscast (http://railscasts.com/episodes/73) and having trouble. The view is projects/new. I''m trying to add some project_people to the form w/code like so: <% form_for(@project) do |f| %> [project stuff here] <% for pp in @project.project_person %> <% fields_for ''project[proj_people_attributes][]'', pp do |pp_form| %> <p> Person: <%= collection_select(:pp, :person_id, Person.get_list, :id, :nom, {:prompt => ''Person?''}) %> Role: <%= select(:pp, :role, Person::ROLE...
2006 Aug 14
1
What fields_for really for?
...egion_id_before_type_cast region_id end validates_numericality_of :region_id, :only_integer => true end ... Its all working now but it looks messy! And I need this functionality in another few places. Obviously I dont want to put this rubbish into other models! I recently come across fields_for helper. So I commented out "unnecessary" code in the model, put these into view: ... <% fields_for :district, @suburb.district do |district_fields| %> <%= district_fields.select :region_id, regions %> <% end %> ... And, guess what, I still need these damn methods in m...
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, lun...
2012 Jan 20
3
Fields_for adding html (text) for hidden field
...;' />'' text printed out in my form. See attached image. I''ve spent too much time trying to figure it out already and it''s not going to stop me from moving on for now. As you can see it''s still very early on. I''m using nested_attributes_for and fields_for: (also HAML) ============================================================= = form_for @user, :url => {:action => ''update''} do |f| # removed fields here = f.fields_for :roles do |r| - unless r.object.for_object.nil? = r.label :role, r.object.for_object.name...
2009 May 12
2
2.3 Nested Model Forms; build new without updating existing
I''m trying to build something similar to a Facebook messaging app, in which the view displays all the messages for a particular thread, with a form box for replying at the bottom of the thread. The problem is that using fields_for generates form fields for each existing record, and for one new record. In this case, there is no need to edit existing messages - just a need to add new messages. Does anybody know how to do this? Code is below. Models: class MessageThread < ActiveRecord::Base has_many :messages accepts_n...
2008 Dec 21
1
Form issues : partials + AJAX vs simple JS / separate views + form_fors vs one view and fields_fors
...tupid to recontact the server just to add a blank <input / >. What is the best way? I also need it to work when Javascript is disabled. Should I use a plain HTML version only that uses one form to add TAs or coprofessors one at a time? Second I''m not sure if my usage of form_for and fields_for is the wisest one. For now, I have one big form (still OK to use I feel) with infos about TAs, coprofessors, periods, places, etc. all in one place. In the back-end of course they are different models so I use a form_for Course and several fields_for (in partials). Should I instead separate it in s...
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 HashWithIndif...
2013 Dec 10
2
form_tag + fields_for Rails 4
Hi There, I''m trying to user fields_for inside a form_tag, but i can''t catch it on my controller. I just take some html code off to makes it easy to read my view... i''m using campuses_path(current_church, @campus) instead form_for @campus, because my route is like resources :campuses, :path => &qu...
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-/JYPxA39Uh5T...
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.sc...
2008 Dec 02
4
Sharing a partial between multiple controllers
...> ''shared/location'', :object => @payee %> A sample of my partial looks like this: <%= location.text_field :address, :size => 60 %> Obviously rails is complaining that the object is not related to a form since I''m not using "form_for" or "fields_for" (see below for error). "undefined method `text_field'' for #<Payee:0x4472530>" How can I make this happen while keeping it DRY? -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are...
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><%= a...
2010 Dec 07
1
fields_for and one out of many from association
...#39;', :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 In the view: <% f.fields_for :primary_address do |address_builder| %> <%= render ''addresses'', :f => address_builder %> <% end %> The ''addresses'' table has a boolean column named ''preferred'' and there should be only one address for the person that is the...
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 working. Looks like simple_fields_for cant work with &qu...