similar to: How to add add child items to parent via parent show view?

Displaying 20 results from an estimated 30000 matches similar to: "How to add add child items to parent via parent show view?"

2006 Sep 07
6
form_for - Child object - how to set parent id
Hi All, I am just trying to learn ruby/rails so please don''t flame me if this is a stupid question. As a learning project I decided to create my own blog using ROR. I have created a controller that shows paged blog entries, and below each blog is a list of comments along with a form alowing the user to add a new comment. To create the form for the comment entry I used form_for
2006 Feb 10
1
validation error reporting on child object
How does one deal with validation error messages on child objects of the main model object behind a page? I have the basic blog w/ comments page (only my "entry" is a "proposal"). I have the comments saving just fine, but I wanted to show an error if the user hits the submit button without typing anything in the comment. I added "validates_presence_of
2006 Aug 14
4
Updating a table with Ajax
I''ve been banging my head against the wall trying to update a table (add/delete rows) using Ajax. It seems simple enough but just doesn''t work for me. I can get it to work using DIVs instead of a table, but doing the layout with DIVs is much more cumbersome and I know it works for others with a table (though I haven''t been able to find an exact example code anywhere).
2006 Aug 08
4
Creating a child simultaneously with parent via form
Hi there I''ve got a user model and an address model; a user has_many addresses. A user object can be created via an html form which also allows for an initial address to be created. I''ve got a controller method working to save both objects via the form, but I suspect I can achieve this in a more rails-esque manner. Here is my controller method: def signup @user =
2006 Mar 13
2
newbie: parent-child view
I have a simple database: a list of manufacturers (parent) and the parts (child) for the manufacturer. >From scaffold, I have a ?show? view listing manufacturers. I modified this view to list the parts for the manufacturer. I also have a link to create a new part. This causes the controller to display a new view to create a new part for the manufacturer. So creating the part is AOK,
2006 Jun 28
3
couple newbie questions
Hello Folks, I am starting out with RoR and just browsed through Dave''s book ? couldn''t stop reading. I started building a prototype to get better hands on experience and I have run into two simple issues that I am hoping will be a quick answer for some of you experts out there. *Issue 1:* >From within a "companies" controller and list_companies.rhtml view
2006 May 15
33
acts_as_commentable release
I now have the acts_as_commentable plugin up on RubyForge. This plugin will allow you to add comments to any active_record object in your Rails application. So far the directions are simple, and there are only a few features: To install: ruby script/plugin install svn://rubyforge.org//var/svn/commentable/acts_as_commentable In the readme there is a sample migration you will need to use, with
2006 Jul 20
3
sort_by with via a parent models child
I am having a problem with ruby''s sort_by function. I want to sort a list of parent model objects based on the children of the parent models. Normally you might say sortedList = modelList.sort_by { |model| model[''someAttribute''] } What I am tring to do is sortedList = modelList.sort_by{ |model| model.children.find(:first, order=>"price desc" ).price}
2006 Mar 14
3
How to save parent and child objects in a single action?
Hi! I''m struggling with it for a week. I posted a few similar posts that cleared up few things (thanks Mark!), but i still don''t know how to do it properly. What i''m trying to do is to create parent object and its many children (images - i tried using file_column, but it''s a topic for another post)using data from a single form. I''ve got a working
2006 Jul 12
0
Parent Child - Transaction Issue
Hi guys, I was trying to create a record in both the parent and child tables (1 to 1 relationship). By default when you call parent.save it''s not invoked in a transaction mode, and I''m trying to avoid parent record is created without the child record (due to validation error in child). I wanted to save both parent and child in transaction mode: parent = Parent.new child =
2006 Jan 25
1
url_for_file_column in parent model''s view
Hi All, I am using the file_column plugin to upload images. The model that I am using is simply called images (id, name, caption - name being the "file" column) and it belongs_to a parent model called books which has_many images. I was able to figure out how to enter the images into the correct model when updating of form of the parent model (books). Now I need to figure out
2010 Apr 09
0
Child to Parent Validation Errors
Hi: Passing child virtual attribute validation error to parent... in case of nested attributes. So, I have a Parent Model say ''Parent''. Nested Attributes it accepts for Child say ''Child'' Now suppose there is a validate method in ''Child'' and it has something like self.errors.add_to_base("some message"). How do you make sure that
2006 Jul 30
1
Insert multiple new child records with the parent
Hello, I am implementing a classic invoice application. On the create new invoice page I want to allow users to add new line items using AJAX: ----------------------------------------------------------------------------- Invoice Date [ ] Client [ ] Line Items 1. [ ] $[ ] <add new line item> <save> <cancel>
2010 Mar 05
15
Three submits, one controller
I have a ''new'' page with a submit for creating stories. On the ''show'' page the submit allows a user to enter comments. I now want a ''edit'' page for the stories with another submit for updates. I have used the ''create'' and ''update'' methods in the stories_controller on the ''new'' and
2006 Feb 21
2
validations and directing errors
I am starting to play with validations as I want to catch errors before SQL rejects inserts to the table which are ugly when nulls are sent to ''Not Null'' columns, etc. If I do something in my model like... validates_format_of :first_name, :with => /^\w+$/, :message => "you moron, enter a name" I still end up
2006 Mar 22
3
Parent-Child Tables Help
can someone help me with this i have a table cars ( id int model_id int make_id int color_id int description text constraint fk_cars_carmake foreign key(make_id) references carmakes(id), constraint fk_cars_carmodel foreign key(model_id) references carmodels(id), constraint fk_cars_color foreign key(color_id) references colors(id) ) carmakes ( id int carmake varchar ) carmodels ( id
2007 Jan 21
1
Strange Ajax Error Since Upgrade
Hi All I''m getting the following very strange Ajax error and I''ve searched Google, this group and various other places to no avail. So I''m desperately hoping someone here can help. Whenever I try to execute any Ajax call whether as a form request or a link_to_remote link I get the following error: ------------------- FORM REQUEST ------------------- [2007-01-21
2006 Dec 30
4
newbie question, "show items in selected city and category"
Hi, rails newbie needs help :) I have classified ads (cads) related with cities and categories: class Cad < ActiveRecord::Base has_and_belongs_to_many :categories has_and_belongs_to_many :cities end class Category < ActiveRecord::Base has_and_belongs_to_many :cads end class City < ActiveRecord::Base has_and_belongs_to_many :cads end I assume that user can act such
2006 Jun 02
0
parent vs child directory permissions problem
I run FreeBSD 4.6-RELEASE (GENERIC) with samba-2.2.4_1 installed. my workstations all run windows xp home or pro with SP2. We're on a workgroup, not a domain. Lately I've been having a problem with changing rights on subfolders. this is my directory structure drwxrwx--- 53 root allstaff 2048 Jun 2 08:19 topdirectory drwxrwx--- 4 Jack group1 512 May 23 13:10
2006 Jun 17
2
how to delete a parent record and child records?
Wow, got myself lost as *soon* as I left the hand-holding exercises in the books. I''m trying to set it up so when I click the (scaffold-generated) ''destroy'' link on one (of a list) of parent MySQL records, the children records in a different table get deleted also. Very simple setup: my tables are ''customers'' and ''accounts'' class