[Rails] Re: accepts_nested_attributes_for

2015-03-09 Thread Sai Ch
please give me the solution. -- 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 unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscr...@goog

[Rails] Re: accepts_nested_attributes_for how, example

2013-11-11 Thread Srdjan Cengic
Thanks Colin on reply. I tried with following code, which work good so just wanted to ask is this correct solution, for some reason i think this code "smell". *// routes.rb* resources :entries, :only =>[:new, :create] *// user.rb* class User < ActiveRecord::Base has_many :entries end *// c

Re: [Rails] Re: accepts_nested_attributes_for, validates_associated, and validates_presence_of within a has_many/belongs_to

2012-08-02 Thread Dave Aronson
On Wed, Aug 1, 2012 at 8:38 PM, John Merlino wrote: > But wouldn't your suggestion that defeat the purpose of using > accepts_nested_attributes_for - where when someone submits > a form with associations, it saves attributes on associated > records through the parent by calling Parent.create, for

[Rails] Re: accepts_nested_attributes_for, validates_associated, and validates_presence_of within a has_many/belongs_to

2012-08-01 Thread John Merlino
But wouldn't your suggestion that defeat the purpose of using accepts_nested_attributes_for - where when someone submits a form with associations, it saves attributes on associated records through the parent by calling Parent.create, for example in the controller responding to the form request On

Re: [Rails] Re: accepts_nested_attributes_for, validates_associated, and validates_presence_of within a has_many/belongs_to

2012-08-01 Thread Dave Aronson
On Wed, Aug 1, 2012 at 12:09 AM, John Merlino wrote: > this will > raise an error, because project_id does not exist yet, since the > project has not been saved yet. Can you create the project first, saving it before you allow the user to even try to add tasks? -Dave -- Dave Aronson, Cleared

[Rails] Re: accepts_nested_attributes_for, validates_associated, and validates_presence_of within a has_many/belongs_to

2012-07-31 Thread John Merlino
I need to rephrase this. Here's the code: class Project < ActiveRecord::Base has_many :tasks accepts_nested_attributes_for :tasks end class Task < ActiveRecord::Base belongs_to :project validates_presence_of :project_id validates_associated :project end Project.create!( :name => '

Re: [Rails] Re: accepts_nested_attributes_for doesn't show output

2011-07-22 Thread Jen
Hi, list. Thanks for the help, nested forms working now. Cheers, Jen! On 21/07/11 15:54, Juan Alvarado wrote: On Jul 21, 2011, at 10:49 AM, Jen wrote: Hi, After getting nowhere I decided to follow this article: http://ryandaigle.com/articles/2009/2/1/what-s-new-in-edge-rails-nested-attribu

Re: [Rails] Re: accepts_nested_attributes_for doesn't show output

2011-07-21 Thread Juan Alvarado
On Jul 21, 2011, at 10:49 AM, Jen wrote: > Hi, > After getting nowhere I decided to follow this article: > > http://ryandaigle.com/articles/2009/2/1/what-s-new-in-edge-rails-nested-attributes > > This meant replicating some already existing fields in my universities/_form, > but I felt it woul

Re: [Rails] Re: accepts_nested_attributes_for doesn't show output

2011-07-21 Thread Jen
Hi, After getting nowhere I decided to follow this article: http://ryandaigle.com/articles/2009/2/1/what-s-new-in-edge-rails-nested-attributes This meant replicating some already existing fields in my universities/_form, but I felt it would atleast rule out the possibility I was doing somethin

Re: [Rails] Re: accepts_nested_attributes_for doesn't show output

2011-07-21 Thread Colin Law
On 21 July 2011 11:55, Jen wrote: Please don't top post, it makes it difficult to follow the thread. Insert your reply at appropriate point(s) in previous post. Thanks. > Hi Colin, > I can't see anything in my controller that indicates I have set @resource to > nil. > When I go directly to the

Re: [Rails] Re: accepts_nested_attributes_for doesn't show output

2011-07-21 Thread Jen
Hi Colin, I can't see anything in my controller that indicates I have set @resource to nil. When I go directly to the resources form it renders fine and I can add data about new resources. It's just when trying to render the form as a partial within the universities/_form view. Do I need to a

Re: [Rails] Re: accepts_nested_attributes_for doesn't show output

2011-07-21 Thread Colin Law
On 21 July 2011 09:29, Jen wrote: > Hi Paul, > Thanks for the reply! > > Am I correct in thinking that for the data my user enters in the fields > relating to resources to be inserted in to the resources table I need to > render a complete form, not just a list of fields? > > I have tried this app

Re: [Rails] Re: accepts_nested_attributes_for doesn't show output

2011-07-21 Thread Jen
Hi Paul, Thanks for the reply! Am I correct in thinking that for the data my user enters in the fields relating to resources to be inserted in to the resources table I need to render a complete form, not just a list of fields? I have tried this approach and am receiving the following error:

[Rails] Re: accepts_nested_attributes_for doesn't show output

2011-07-20 Thread paul h
On Jul 19, 11:33 pm, Jen wrote: > I forgot to mention that currently each of my tables is handled by a > separate controller. A controller is simply an entry/access point, you can pull in data from any model in any controller and pass it to any view to be used. > > I thought this would be ok a

[Rails] Re: accepts_nested_attributes_for doesn't show output

2011-07-20 Thread paul h
On Jul 17, 10:27 pm, Barney wrote: > Hello, >      An earlier post where I asked how to put mulitple tables's input > on one screen was answered with "accepts_nested_attributes_for" and > that seems to be what I need, but nothing appears on the screen for > the nested section.  I've been using i

[Rails] Re: accepts_nested_attributes_for and _destroy not working (but no error messages)

2011-04-14 Thread skt
Couple things you can try - 1. Where you have _destroy="false" replace that with _destroy="0" - just in case something is throwing that parser out of whack 2. Try _delete instead of _destroy - been a while but I remember in one of my setups _delete worked but not _destroy -S On Apr 14, 10:42 pm,

[Rails] Re: accepts_nested_attributes_for - issue

2010-03-29 Thread Art Shayderov
It really helps if you post as much information as possible. In this particular case your form html (I mean from page source in browser) and request params would be very helpful. I'm not an expert in nested forms but it's probably because you are receiving an array instead of a hash in a request.

[Rails] Re: accepts_nested_attributes_for - issue

2010-03-28 Thread slindsey3000
Yes, you are correct. Terrible naming. But was done to try quick example. I am creating new player so @cpr it won't find player because I am in fact creating one. I know... terrible code. It seems to be looking for Active Record object and I am passing in array... Help! On Mar 28, 6:08 am,

[Rails] Re: accepts_nested_attributes_for - issue

2010-03-28 Thread Art Shayderov
It's rather unusual to name the action 'index' when it shows form for creating a new object. Why not call it 'new' or something like that. And then the action is named 'update_player' when in fact it is creating a new Player object. Why don't you name it 'create'? I'm sorry for nitpicking but choos

[Rails] Re: accepts_nested_attributes_for - issue

2010-03-28 Thread cpr
I haven't tried running your code, but please change: def update_player @player = Player.new(params[:player]) @player.save redirect_to :action => :index end to def update_player @player = Player.find_by_id(params[:id]) @player.update_attributes(params[:player]) r

[Rails] Re: accepts_nested_attributes_for abilities

2010-02-09 Thread Marnen Laibow-Koser
John Merlino wrote: > > > Is there a way to use accepts_nested_attributes_for to update another > table from within a controller. For example, I have this in my students > controller: > > def student_fail > @student = Subject.find(params[:id]) if params[:id] > @student.build_student_fail > end

[Rails] Re: accepts_nested_attributes_for :has_many :through => 'bug?'

2010-01-26 Thread mark
Thanks for having a look Matt, I've changed <% f.fields_for :companies do |company| %> to <% f.fields_for :companies_attributes do |company| %> and i'm no longer getting the "expected object, but got array error", now i'm getting "undefined method `stringify_keys' for "test":String" where "test

[Rails] Re: accepts_nested_attributes_for :has_many :through => 'bug?'

2010-01-26 Thread Matt Jones
On Jan 25, 7:34 pm, mark wrote: > 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 mak

[Rails] Re: accepts_nested_attributes_for + paperclip + polymorphic + problem

2009-12-18 Thread andresgutgon
Thanks, it worked for me to :D On Dec 7, 1:41 pm, Antony Sastre wrote: > Hi Ab, > > The form view should read: > > <% form_for @office, :html => {:multipart => true} do |f| %> > > This is always the case when dealing with file uploads. > > On Dec 7, 9:05 am, Abhishek shukla wrote: > > > Hello Fr

Re: [Rails] Re: accepts_nested_attributes_for + paperclip + polymorphic + problem

2009-12-07 Thread Abhishek shukla
antony thanks. It worked,. On Mon, Dec 7, 2009 at 6:11 PM, Antony Sastre wrote: > > Hi Ab, > > The form view should read: > > <% form_for @office, :html => {:multipart => true} do |f| %> > > This is always the case when dealing with file uploads. > > > On Dec 7, 9:05 am, Abhishek shukla wrote:

[Rails] Re: accepts_nested_attributes_for + paperclip + polymorphic + problem

2009-12-07 Thread Antony Sastre
Hi Ab, The form view should read: <% form_for @office, :html => {:multipart => true} do |f| %> This is always the case when dealing with file uploads. On Dec 7, 9:05 am, Abhishek shukla wrote: > Hello Friends, > > I am not able to retrieve the value form page > > controller >   offices_contr

RE: [Rails] Re: accepts_nested_attributes_for and belongs_to

2009-12-01 Thread Joe McGlynn
_many child relationship. -Original Message- From: Claudio Poli [mailto:masterk...@gmail.com] Sent: Tuesday, December 01, 2009 10:20 AM To: Ruby on Rails: Talk Subject: [Rails] Re: accepts_nested_attributes_for and belongs_to sorry, but I'm trying to update an attribute of a parent mod

[Rails] Re: accepts_nested_attributes_for and belongs_to

2009-12-01 Thread Claudio Poli
sorry, but I'm trying to update an attribute of a parent model.. On 1 Dic, 19:12, "Joe McGlynn" wrote: > I put together a sample app that shows how to do this. > > Details here:https://joemcglynn.wordpress.com/wp-admin/ > The project can be downloaded from > github:http://github.com/canonical/Or

[Rails] Re: accepts_nested_attributes_for - objects are ignored:

2009-08-14 Thread Jan Lühr
Hello, On Friday 14 August 2009 18:59:19 Jan Lühr wrote: > I've encountered some annoying problem with accepts_nested_attributes_for > Model is: http://pastie.org/584213 > Request is: http://pastie.org/584216 > Controller is: http://pastie.org/584222 > Record before request = Record after reques

[Rails] Re: accepts_nested_attributes_for :reject_if issue

2009-06-25 Thread Andrei Don
Andrei Don wrote: > 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|

[Rails] Re: accepts_nested_attributes_for has_one issue

2009-06-10 Thread Richard Shank
Richard Shank wrote: > tho...@icdesign.com.au wrote: >> Richard, >> I had a go at it the other day and strangely enough it was all working >> fine, I threw my demo up on github so maybe you can check it out to >> help fix your problem: >> >> http://github.com/anathematic/has_one_problem/tree/mast

[Rails] Re: accepts_nested_attributes_for has_one issue

2009-06-10 Thread Richard Shank
You beat me to the punch! :) -- 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@googlegroups

[Rails] Re: accepts_nested_attributes_for has_one issue

2009-06-10 Thread John Butler
Richard Shank wrote: > tho...@icdesign.com.au wrote: >> Richard, >> I had a go at it the other day and strangely enough it was all working >> fine, I threw my demo up on github so maybe you can check it out to >> help fix your problem: >> >> http://github.com/anathematic/has_one_problem/tree/mast

[Rails] Re: accepts_nested_attributes_for has_one issue

2009-06-10 Thread Richard Shank
tho...@icdesign.com.au wrote: > Richard, > I had a go at it the other day and strangely enough it was all working > fine, I threw my demo up on github so maybe you can check it out to > help fix your problem: > > http://github.com/anathematic/has_one_problem/tree/master > > Thomas > > > > On

[Rails] Re: accepts_nested_attributes_for has_one issue

2009-06-09 Thread tho...@icdesign.com.au
Richard, I had a go at it the other day and strangely enough it was all working fine, I threw my demo up on github so maybe you can check it out to help fix your problem: http://github.com/anathematic/has_one_problem/tree/master Thomas On Jun 10, 4:05 pm, Richard Shank wrote: > >> On May 22,

[Rails] Re: accepts_nested_attributes_for has_one issue

2009-06-09 Thread Richard Shank
>> On May 22, 5:45�am, John Butler > > No i didnt find a solution but ill have to revisit it in the next couple > of days, > > looks like ti should work but ill have to get into the guts of whats > happening to find out, > > JB Any progress on this? I'm in the middle of the same problem.

[Rails] Re: accepts_nested_attributes_for has_one issue

2009-06-04 Thread John Butler
tho...@icdesign.com.au wrote: > I'm having just the same problem at the moment, was there a solution > posted for this? > > On May 22, 5:45�am, John Butler No i didnt find a solution but ill have to revisit it in the next couple of days, looks like ti should work but ill have to get into the

[Rails] Re: accepts_nested_attributes_for has_one issue

2009-06-04 Thread tho...@icdesign.com.au
I'm having just the same problem at the moment, was there a solution posted for this? On May 22, 5:45 am, John Butler wrote: > >I would try doing the equivalent on the Rails console, so just loading > > a user object, setting 'user_detail_attributes' attribute, then saving > > and see if that wo

[Rails] Re: accepts_nested_attributes_for has_one issue

2009-05-21 Thread John Butler
>I would try doing the equivalent on the Rails console, so just loading > a user object, setting 'user_detail_attributes' attribute, then saving > and see if that works so any view/controller code can be ruled out. > Also I think posting the code in the controller's create action would > be useful

[Rails] Re: accepts_nested_attributes_for has_one issue

2009-05-21 Thread Andrew France
Hi JB, On May 21, 4:24 pm, John Butler wrote: > Im having an issue with accepts_nested_attributes_for for a has_one > relationship.  I have posted the code below and the parameters sent to > the create but this is not saving the user_detail association record. > View code looks fine at a glance