Displaying 20 results from an estimated 9000 matches similar to: "nested attributes form"
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
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
2009 Jul 01
2
Nested Forms - how to displayed the attributes content ?
I have a User model
class User < ActiveRecord::Base
has_one :account
accepts_nested_attributes_for :account, :allow_destroy => true
validates_associated :account
attr_accessible :account_attributes
is working fine, validating and updating both records (User and
Account), but I caanot display the value in the form when is updated,
ex: below the firstname is not displayed but
2012 Sep 29
0
rails 3.2 nested form names not correct
I have a person has many questions model, I have accepts_nested_Attributes
set up properly. the question from the db show up, but the index is not
incrementing:
<%= f.fields_for :person_questions do |pregunta| %>
Questions: <br/>
<% Question.all.each do |question| %>
<%= render ''questions/question_type'', :pregunta =>
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 =
2010 Oct 15
1
Help with nested form: User and Artist
Artist is 1:1 with User. User has_one :artist
In my artist model, I have:
belongs_to :user
accepts_nested_attributes_for :user
However, in my artist _form, the name column from the user model does
not display. I am doing:
<% f.fields_for :user do |builder| %>
<p class="fields">
<%= builder.label :name %>
<%= builder.text_field :name %>
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 %>
2009 Jul 15
0
has_many and has_one ... and nested form
Hiya
I am looking at Rails 2.3.2 and how to cleanly do the following:
- I have model User
- User has many Plans
- User has one Active Plan
- New User form has fields on it to create the Active Parent
I want to create a new User with an Active Plan in one form.
At the moment I have:
class User < ActiveRecord::Base
has_one :active_plan, :class_name => ''Plan'',
2011 Nov 04
1
add dynamic nested attributes without nested form gem
Hello people
In my rails 3.0.9 app I''m trying to add nested attributes
dynamically, but I don''t want to use "nested form gem"
So I found this example
https://github.com/alloy/complex-form-examples/blob/a234fde4419836f277d7e340657f1d8418911d68/app/helpers/projects_helper.rb
but this code doesn''t work
module ProjectsHelper
def
2009 Sep 21
0
Polymorphic form
I have two partials to deal with contact information. The Contact
information uses single-table polymorphism. I want to be able to use
save on Contact and set ''type'' manually, based on the type of form the
user is filling in. This is saved as the value on a hidden field.
class Contact
belongs_to :person
acts_as_list :scope => :person
validates_presence_of :type
2011 Mar 02
2
Nested forms validation problem
Hi All,
I''m trying to learn Ruby on Rails and have got an issue with the
validation of a nested form. I think I have got it setup correctly as it
appears to be saving the data as expected, but it is not wrapping the
CSS class (field_with_errors) to the fields, and if data is entered into
the nested fields it disappears on form submit (if there are validation
errors). The validation
2011 May 17
0
Select not maintaining state on nested form with
I am using nested forms with multiple instances of various of the forms. The
problem I cant figure out is how to maintain state for the select between
postbacks. I am using ''options_from_collection_for_select'' and in this the
last param is to be the selected value, but given the dynamic nature, the
value is going to depend on the iteration of the form builder. If I manually
force
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
2012 Sep 08
4
dash symbol
In the example below, what is the dash doing between the class
attribute and array:
(field_helpers -
[:label, :check_box, :radio_button, :fields_for, :hidden_field, :file_field]).each
do |selector|
--
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
2012 Oct 06
0
rails 3.2 question/answer with a through table
I have a person has many questions through person_questions. I have an
extra column in the join table for the answer. The section below works for
a new submit but when I edit I get 3 each with the first 2 of each selected
tand the third not so I get 6 check boxes some selected some not. Is there
a way to get this to work properly os just the questions in the db show up
once each with the
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:
2011 Mar 10
4
Multi-model forms
Hi guys, I''m new to ruby and rails and I''m working on multi model
forms, specifically 3. I''m using this http://guides.rubyonrails.org/getting_started.html
as a start, and its got a 2 Model example but I cant seem to get the
last one working.
These are my models:
Country name:string code:string (has_one :address)
Address address_line1:string
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
2010 Apr 12
3
$(link).previous("input[type=hidden]") is undefined
I am getting this error when trying to use the remove link explained
in the Railscast:
http://railscasts.com/episodes/197-nested-model-form-part-2
error:
$(link).previous("input[type=hidden]") is undefined
remove_fields()applic...1065175 (line 6)
function onclick(event) { remove_fields(this); return false; }()1
(line 2)
[Break on this error]
2006 Jul 20
2
using association properties in form helpers
sorry for the noob question:
how do i reference an association''s properties in a form helper?
e.g. if i wanted to build a select list to choose a user''s address''s
state (user.address.state), how would i hook that to the "method" of
collection_select
collection_select :user, ???, States.find(:all)