similar to: Order parents when displaying children question

Displaying 20 results from an estimated 7000 matches similar to: "Order parents when displaying children question"

2008 Jun 29
2
How to write test about validates_associated
Here is my model: class Account < ActiveRecord::Base has_many :users, :dependent => :destroy has_many :bus belongs_to :currency has_many :mylogs, :dependent => :destroy has_many :batchuserdefines, :dependent => :destroy has_many :materialuserdefines, :dependent => :destroy has_many :materials has_many :inventories has_many :batchs has_many :courses has_many
2006 Jan 11
0
Easy Question, I Think
I am just getting started with Rails, don''t know any Ruby, and don''t quite even get object oriented programming yet. I have tweaked my schema to The Rails Way and have generated a bit of scaffolding. I am trying to create a new Part, which references a PartName and a PartNumber. I can create a PartNumber on the fly, but the PartName has to exist. I have an inelegant solution
2006 Jan 12
0
Easy Question, I Think [re-post, sorry if dupe]
I am just getting started with Rails, don''t know any Ruby, and don''t quite even get object oriented programming yet. I have tweaked my schema to The Rails Way and have generated a bit of scaffolding. I am trying to create a new Part, which references a PartName and a PartNumber. I can create a PartNumber on the fly, but the PartName has to exist. I have an inelegant solution
2005 Dec 17
0
bug? saving (valid) updated object results in validation error
Hi! I have an error that I don''t understand. It shouldn''t be happening, according to the documentation! I have a class, defined as below. > class Coupon < ActiveRecord::Base > belongs_to :product > belongs_to :account > validates_presence_of :product > validates_associated :product > validates_presence_of :voucher > validates_presence_of
2006 May 28
3
Validating Foreign Key
Howdy, I''m a Rails beginner working on my first significant project with RoR. I''m trying to figure out how to validate a foreign key (you know, make sure the row actually exists.) However, validates_associated doesn''t seem to be what I want to use, nor does it work... -- BEGIN -- class City < ActiveRecord::Base has_many :schools belongs_to :state
2005 Dec 29
3
Verification problems
Hello, Hope this isn''t a newbie question - but I don''t seem to be able to find relevent information elsewhere. I am having trouble getting the following to work: Schema ====== ActiveRecord::Schema.define(:version => 1) do create_table "authors", :force => true do |t| t.column "name", :string end create_table "books", :force =>
2008 Jul 01
6
validates_associated & foreign keys
Hi, I''m struggling to get the validates_associated to work as I think it should be. I''m using: JRuby 1.1 rails-2.0.2 activerecord-2.0.2 activerecord-jdbc-adapter-0.8.2 My tables in MySQL: CREATE TABLE area_codes ( id INT UNSIGNED auto_increment primary key ... ); CREATE TABLE markets ( id INT UNSIGNED auto_increment primary key, ... ); CREATE TABLE
2006 Jan 03
4
validates_presence_of *_id attributes
Hi all, I am a newbie to Rails. Please enlighten me on how to do this appropriately, the Rails and the Ruby way: Suppose I have a Recipe model. Let''s simplify things and pretend that it has only 2 attributes, a :name and the other is a ''category_id''. In the recipes table, category_id is a foreign key to field id of table categories. We also assume that I have generate
2006 Jan 03
6
Am I going too far or Rails is just confusing? was {validates_presence_of *_id attributes}
Thanks for the input Blair Zajac and Chris (Nolan and Hall), and for others. If all of you have time, please follow this (the question still relates to the previous posts by me): I have provided full steps to reproduce the symptoms. If it matters, I''m running Ruby 1.8.2, Rails 1.0, and MySQL 5.0.15 on Windows XP Professional. 1. First, the setup MySQL ----- create database testdb;
2009 Nov 20
3
Ensuring that foreign key is valid
I am trying to set up a validation in a model to ensure that a record can''t be saved unless the foreign key it belongs_to is a valid record. My model says: class Admin < ActiveRecord::Base validates_presence_of :user_id validates_numericality_of :user_id validates_uniqueness_of :user_id validates_associated :user belongs_to :user end but I can still create an admin
2005 Aug 19
2
data validation
I''m trying validate date before they''re stored into the DB, but it seems, validation doesn''t work.. my model looks like this: class Company < ActiveRecord::Base has_many :contacts, :foreign_key =>''company_id'' has_and_belongs_to_many :categories, :join_table => ''company_to_category'', :foreign_key =>
2006 Jan 19
0
file_column error: tmp file created but not actual
Hi When I submit the form with field_column, the actual image is not uploaded, only temp files are crreated and I dont see actual file created and the image file name is not in the database and get "fieldWithErrors". Then if submit again, the actual file in created and an database record is generated. Here is the log file. I print @params and @wallpaper. I find the following: 1st
2007 Aug 23
6
controller spec with model that validates_uniqueness
I want to use mocks and stubs to test the controller, but am having trouble getting my validation not to trigger. Here''s the code: # spec: Image.stub!(:find).and_return(@image) @image.should_receive(:save!).once.with(:any_args) put :update, :id => @image.id, :category_id => @category.id, :image => {:name => ''test'', :image_number =>
2006 May 11
1
RoR completely ignoring a column when saving changes
I have an action that needs to update two models/two tables in one shot, and it works great, but ignores one column. Here is the action code: (verify_id is irrelevant in this case) [CODE] def edit @page_title = "Edit User" @page_active_3 = "active" if request.post? @user = User.find(params[:id]) @profile = @user.profile verify_id(@user.id,
2009 Jan 09
3
What is wrong with validates_presence_of :my_association ?
Category.has_many :products Let''s say a product must belong to a category. I know it is recommended to do the following: class Product validates_presence_of :category_id end But, as we all know, this is a pain for new records, meaning what if the associated category is a new record? I''ve been meaning to ask this, but what''s wrong with doing the following: class
2005 Nov 15
0
validates_associated
I have an db table that associates two things from the same table. people_alt_people ----------------- person_id alt_person_id So my ActiveRecord looks like: class PeopleAltPerson < ActiveRecord::Base belongs_to :person belongs_to :altperson, :class_name => ''Person'', :foreign_key => ''alt_person_id'' validates_presence_of :person
2006 Jun 13
6
Dead horse: validates_associated
Regarding validates_associated... Let''s say I have: article belongs_to author But for whatever reason, I want an article to also be written anonymously and therefore not require an author. Then I have: Article: belongs_to :author validates_associated :author But I DON''T have validates_presence_of. What I want to do is validate that an author is valid --if it is
2005 Oct 12
4
Validating 2 related models at once not working
Hello, I have a form that submits data to two related models/tables. One is Customer the other is Address. Validation for Customer works fine but not for the Address. Class Customer < ActiveRecord::Base has_one :address validates_presence_of :login, :password, :email validates_associated :address end Class Address < ActiveRecord::Base belongs_to :customer validates_presence_of
2006 Jan 20
3
Is there a way to validate a model w/o saving it?
I have some code in my controller which looks like this: if request.post? and @account.save and @user.save ... end and in my Account and User models I have many :validates, like so account.rb validates_presence_of :subdomain, :on => :create validates_uniqueness_of :subdomain, :on => :create, :message => "is already being used" validates_exclusion_of
2007 Jun 21
1
Validation Through Multiple Models from one Form
Hey All, I have a form that submits data to multiple models. I have class Man < ActiveRecord::Base has_many :notes has_many :contacts validates_associated :contacts, :notes validates_presence_of :first_name validates_presence_of :last_name class Contact < ActiveRecord::Base belongs_to :man validates_presence_of :contact_info class Note < ActiveRecord::Base