Ok, I've followed this cast http://railscasts.com/episodes/197-nested-model-form-part-2 but I get an error when I try to add the link to "add fields" (remove works as expected) this is the error
NoMethodError in Projects#new Showing /home/angelo/nestattr/app/views/projects/_form.html.erb where line #24 raised: undefined method `klass' for nil:NilClass Extracted source (around line #24): 21: <%= render "task", :f => t %> 22: <% end %> 23: <p> 24: <%= link_to_add_fields "Add task", f, :task %> 25: </p> 26: <div class="actions"> 27: <%= f.submit %> Currently I'm using rails 3.0.9, so maybe something has changed since then, please, tell me what's wrong On 4 nov, 15:48, Angelo Cordova <acord...@gmail.com> wrote: > 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/a234fde4419836f27... > > but this code doesn't work > > module ProjectsHelper > def remove_link_unless_new_record(fields) > unless fields.object.new_record? > out = '' > out << fields.hidden_field(:_delete) > out << link_to_function("remove", "$ > (this).up('.#{fields.object.class.name.underscore}').hide(); $ > (this).previous().value = '1'") > out > end > end > end > > I think that lines which starts with "out <<" make some conflicts, > because I've checked the html (firebug) and the simbols "<" and ">" > doesn't appear > > <a href="#" onclick="$(this).up('.task').hide(); $ > (this).previous().value = '1'; return false;">remove</a> > > Can you help me please?? Thanks -- 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@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.