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
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
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
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
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
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 => '
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
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
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
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
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
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
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:
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
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
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,
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.
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,
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
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
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
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
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
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
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:
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
_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
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
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
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|
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
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
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
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
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,
>> 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.
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
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
>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
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
40 matches
Mail list logo