[Rails] accepts_nested_attributes_for

2015-03-09 Thread Sai Ch
Hello, I'm using accepts_nested_attributes_for for my project. Models Course: belongs_to :user has_many :holes has_many :scores accepts_nested_attributes_for :holes Hole : belongs_to :user belongs_to :course

[Rails] Rails, accepts_nested_attributes_for has_many: through with build

2013-12-20 Thread Srdjan Cengic
I have 3 models: class Product < ActiveRecord::Base has_many :product_option_types has_many :option_types, through: :product_option_typesend class OptionType < ActiveRecord::Base has_many :product_option_types has_many :products, through: :product_option_typesend class ProductOptio

Re: [Rails] accepts_nested_attributes_for how, example

2013-11-11 Thread Srdjan Cengic
Thanks Colin on reply. I tried with following code, which work good but i don't know how to create row in *votes* table. *// routes.rb* resources :entries, :only =>[:new, :create] //* entries_controller.rb* class EntriesController < ApplicationController def new @entry = Entry.new(*:user_i

Re: [Rails] accepts_nested_attributes_for how, example

2013-11-11 Thread Colin Law
On 10 November 2013 23:24, Srdjan Cengic wrote: > I have following tables with following models: >users(id, role_id) has_many :entries >categories(id, category_name) has_many :entries >entries(id, category_id, user_id) belongs_to :user, belongs_to > :category, has_one :sto

[Rails] accepts_nested_attributes_for how, example

2013-11-10 Thread Srdjan Cengic
I have following tables with following models: users(id, role_id) *has_many :entries* categories(id, category_name) *has_many :entries* entries(id, category_id, user_id) *belongs_to :user, belongs_to :category, has_one :storage* storages(id, title, content, entry_id)*

[Rails] Accepts_nested_attributes_for gives mass assignment error when roles are used

2012-10-24 Thread Kristian Rasmussen
Hi, I've got a rails question. I get a MassAssignmentSecurity::Error when I do the following: class User < ActiveRecord::Base default = [:first_name, :last_name] attr_accessible *default attr_accessbile *default, :metadatas_attributes, as: :admin has_many :metadatas accepts_neste

[Rails] accepts_nested_attributes_for and fields_for not working!

2012-08-26 Thread Sarah
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,

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

2012-07-31 Thread John Merlino
In a popular Rails book: http://books.google.com/books?id=slwLAqkT_Y0C&pg=PT366&lpg=PT366&dq=%22validates_associated+in+conjunction+with+validates_presence_of%22&source=bl&ots=9bZwHNjzvG&sig=aTN0WnknjzZ0WfRd9PeJGxQSAEU&hl=en&sa=X&ei=RagYUM_zH4T89gTW_YDwCw&ved=0CC8Q6AEwAA#v=onepage&q=%22validates_a

Re: [Rails] accepts_nested_attributes_for.

2011-11-11 Thread Colin Law
On 11 November 2011 09:50, Mauro wrote: > Example: > > accepts_nested_attributes_for :tags, :allow_destroy => :true, >   :reject_if => proc { |attrs| attrs.all? { |k, v| v.blank? } } > > :reject_if  prevents saving new tags that do not have any attributes filled > in. > But if in Tag model I use

[Rails] accepts_nested_attributes_for.

2011-11-11 Thread Mauro
Example: accepts_nested_attributes_for :tags, :allow_destroy => :true, :reject_if => proc { |attrs| attrs.all? { |k, v| v.blank? } } :reject_if prevents saving new tags that do not have any attributes filled in. But if in Tag model I use validates contraints it's the same thing? So I can avoi

[Rails] accepts_nested_attributes_for is not working for uniqueness

2011-09-27 Thread Rajeev Kannav Sharma
class User < ActiveRecord::Base accepts_nested_attributes_for :emails, :allow_destroy => true, :reject_if => proc { |attributes| attributes['address'].blank? } end class Email < ActiveRecord::Base belongs_to :user validates_presence_of :address validates_email_format_of :address

[Rails] accepts_nested_attributes_for issue

2011-09-06 Thread Abhishek shukla
Hello, I am using accepts_nested_attributes_for for saving the records. let say I have a model class User < AR::Base has_many :books accepts_nested_attributes_for :books end class Book < AR::Base belongs_to :user end Now the params value I am getting is user={:id => 123, books_attribute

Re: [Rails] accepts_nested_attributes_for doesn't show output

2011-07-21 Thread Tom Meinlschmidt
guy, you're using f.label, so then you have to use f.fields_for :something do |smth| smth.label :label, "description" smth.text_field ... On Jul 21, 2011, at 16:49 , Jen wrote: > Hi, > After getting nowhere I decided to follow this article: > > http://ryandaigle.com/articles/2009/2/1/wha

Re: [Rails] accepts_nested_attributes_for doesn't show output

2011-07-20 Thread Juan Alvarado
Sent from my iPad On Jul 19, 2011, at 6:33 PM, Jen wrote: > I forgot to mention that currently each of my tables is handled by a separate > controller. > > I thought this would be ok and anything entered in my resources _form partial > would be handled by the 'resources' controller etc. How

Re: [Rails] accepts_nested_attributes_for doesn't show output

2011-07-19 Thread Jen
I forgot to mention that currently each of my tables is handled by a separate controller. I thought this would be ok and anything entered in my resources _form partial would be handled by the 'resources' controller etc. However looking at the rails cast source code has confused me a bit, as it

Re: [Rails] accepts_nested_attributes_for doesn't show output

2011-07-19 Thread Jen
Hi Barney, I believe I am having the same problem you experienced, though my code is a little different. If you or anyone else can tell me how to solve it that would be great! I am creating a db of Universities and resources. One University can have many resources, but one resource can o

[Rails] accepts_nested_attributes_for doesn't show output

2011-07-17 Thread Barney
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 ideas from: http://masonoise.wordpress.com/2010/

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

2011-04-14 Thread Niklas Nson
I have a has_many association and does some adding throug a nested form, i can add objects (images) and edit text this works fine. But when i try to delete items nothing happens. This is what my log looks like: Started POST "/photosets/168" for 127.0.0.1 at Fri Apr 15 07:34:04 +0200 2011 Processi

[Rails] accepts_nested_attributes_for - issue

2010-03-27 Thread slindsey3000
Just trying a simple example to try to get nested to work... but can't get it! Been 2 days! Please help. VERY SIMPLE controller, view, models... listed below. --ERROR MESSAGE-- ActiveRecord::AssociationTyp

[Rails] accepts_nested_attributes_for vs. multiple controllers on one page

2010-02-25 Thread Grary
Hi, I'd like to render the results from show, create, edit and delete actions for several different models (one controller per model) on one page. While these several models are conceptually related, they do not need to be associated with each other. So, I'd rather not impose associations on them

[Rails] accepts_nested_attributes_for abilities

2010-02-09 Thread John Merlino
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 def student_fail_finalize if @student.u

Re: [Rails] accepts_nested_attributes_for with has_many => :through

2010-02-06 Thread tommy xiao
have a look: http://railscasts.com/episodes/73-complex-forms-part-1 http://railscasts.com/episodes/73-complex-forms-part-2 http://railscasts.com/episodes/73-complex-forms-part-3 2010/2/6 acreadinglist > I have two models, links and tags, associated through a 3rd model, > link_tags. I added the

[Rails] accepts_nested_attributes_for with has_many => :through

2010-02-06 Thread acreadinglist
I have two models, links and tags, associated through a 3rd model, link_tags. I added the following to my link model, has_many :tags, :through => :link_tags has_many :link_tags accepts_nested_attributes_for :tags, :allow_destroy => :false, :reject_if => proc { |attrs| attrs.all? { |k, v|

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

2010-01-25 Thread mark
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 :relationsh

[Rails] accepts_nested_attributes_for + paperclip + polymorphic + problem

2009-12-07 Thread Abhishek shukla
Hello Friends, I am not able to retrieve the value form page controller offices_controller def new @office = Office.new end def create @office = Office.new(params[:office]) @office.save end end VIEW <% form_for @office do |f| %> <%= f.text_area :office_na

RE: [Rails] accepts_nested_attributes_for and belongs_to

2009-12-01 Thread Joe McGlynn
, December 01, 2009 10:08 AM To: Ruby on Rails: Talk Subject: [Rails] accepts_nested_attributes_for and belongs_to hi everyone, using Rails 2.3.5 I cannot update the attributes for a belonging object, pastie: http://pastie.org/722059 ideas? thanks -- You received this message because you are

[Rails] accepts_nested_attributes_for and belongs_to

2009-12-01 Thread Claudio Poli
hi everyone, using Rails 2.3.5 I cannot update the attributes for a belonging object, pastie: http://pastie.org/722059 ideas? 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-t...@go

[Rails] accepts_nested_attributes_for - objects are ignored:

2009-08-14 Thread Jan Lühr
Hello, 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 request: http://pastie.org/584225 Within the request, asemployees_

[Rails] accepts_nested_attributes_for and ActiveResources

2009-07-23 Thread dl
Does accepts_nested_attributes_for work with ActiveResources? --~--~-~--~~~---~--~~ 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 unsu

[Rails] accepts_nested_attributes_for and has_one

2009-07-08 Thread Jack H
Hi all, I'm seeing some unexpected behaviour in a nested model and I'm not sure if it's a bug or if I'm doing something wrong. When assigning nested attributes, the associated object gets replaced with a new record. Example code: class Car < ActiveRecord::Base belongs_to :driver end class Ca

[Rails] accepts_nested_attributes_for :reject_if issue

2009-06-24 Thread Andrei Don
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| attributes['has_shipping_address'] !=

[Rails] accepts_nested_attributes_for has_one issue

2009-05-21 Thread John Butler
Hi, 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. Ive tried various solutions from the links below but cant get this to work. Can an

[Rails] accepts_nested_attributes_for and add/remove nested model forms with JS

2009-05-20 Thread Branko Vukelic
I've looked at the complex_form example app on GitHub, but I'm not sure I understand how it works. For now I've managed to display the partial using the render command, and stopped at the "add new item" link... Here's the current code: <%= f.error_messages %> <%= f.label :name %>