similar to: Noob: Validation Errs Don''t Display When Saving Object Tree

Displaying 20 results from an estimated 10000 matches similar to: "Noob: Validation Errs Don''t Display When Saving Object Tree"

2006 Jan 11
7
Create a relationship with 2 or more tables on 1 insert
userstable: |id|name|password| userdetailstable: |id|col1|col2|col3|user_id| this is my code: [code] def create @user = User.new(@params[''user'']) @userdetail = Userdetail.new(@params[''userdetail'']) if @user.save and @userdetail.save flash[:notice] = "Save succeeded..." redirect_to :action => ''list''
2006 Jul 19
1
Updating a model from a checkbox (noob question)
Hello everyone, I''m trying to wire a combobox in a view to update the database. When I select something in the combobox and press ''update'' it goes through fine, except it places the default value for the field of the combobox. Any suggestions? Here''s the model: class TestResult < ActiveRecord::Base has_one :status_index has_one :test_type has_one
2006 Sep 01
2
Mrelation does not exists
Hello! I''m having the following error: RuntimeError: ERROR C42P01 Mrelation "subjects_users_id_seq" does not exist Fnamespace.c L200 RRangeVarGetRelid: SELECT currval (''subjects_users_id_seq'') when I try to do: subject= SubjectsUser.new(params[:subjects_user]) subject.save The models: class User < ActiveRecord::Base has_one :last_entrie has_one
2006 Jan 10
5
Noob ActiveRecord Join Question
I''m new to rails and ruby, and after trying to get this to work correctly for hours, I thought I''d give this forum an try. I''ve setup a trivial project just to mess around with Rails database naming conventions and associations. I''ve got a table called Pets, and a table called Types. Pets contains a list of pets, Parky the cat, Daisy the dog, etc, And Types
2006 Jul 08
2
Creating/Saving dependent objects
Folks, Am new to RoR and am building an example to get myself familiar. I am running into a simple issue while creating a user registration page. I have a User and Address models defined as below (partial/relevant code included below). User has_one address and Address belongs_to user. I have a foreign key defined in address table that refers to user(id) In a form I take in username, password,
2006 May 17
4
NOOB: Representing linked objects in one form
Given two models: User :name :email :address_id # foreign key Address :line_1 :line_2 :city etc. I want to have a form allowing a user to register, in which she''d enter an address as well, but how do I go about combining both objects into the one form? I''m new to this and following along with the Agile Rails book from the Pragmatic Programmers, but it
2006 Jan 10
8
Noob: Child records not saved
Hi all, happily coding along, but it seems a belongs_to record is not saved. # Create some stuff def create_project @contact = Contact.new @project = Project.new(@params[''project'']) @project_contact = ProjectContact.new(@params[''collect'']) @project.project_contact = @project_contact contact =
2007 May 14
0
building and saving has_many and has_one relations
Hi, I am very confused about an aspect of has_one and has_many relations, with regard to using the build method, and saving the belongs_to side. It''s a somewhat long post. so please bear with me :) First let''s consider the has_one scenario. Let''s say I have a student who must own exactly one car: class Student has_one(:car) end class Car belongs_to(:student)
2009 Jun 20
0
[Rails 2.3] nested_attributes and validation of nested model
Hi, I''m using nested models to create form in my view. It looks like this: <% form_for :user, :url => {:action => "add_owner" }, :html => { :method => :post } do |u| %> <li><label>Name: </label><%= u.text_field :name %></li> <li><label>Surname: </label><%= u.text_field :surname %></li> <%
2008 Aug 21
1
wildcards and prefix searches
Hey all, I'm using Xapian through acts_as_xapian and would like to know why trailing wildcards do not work on prefix searches. Specifically, I have a Merchant model with a Description field, mapped to the prefix "desc". If I then search for "desc:goods" I get 4 matches, but if I search for "desc:goo*" I get 0. However, when searching normal, non-prefixed
2006 Jul 06
4
has_one, belongs_to - I am just not getting it
Let me preface by saying i''m a total noob at ruby/rails. :-) For some reason, I am just not grasping the concept of has_one & belongs_to... I''m working on a project that includes user authentication, and 3 different types of user profiles. User profiles are either "fan", "band", or "venue" objects, and user logins are "user"
2006 May 11
18
Object constructors - Noob Question
Hi: Sorry if this is a painfully stupid question... I have some data I need through the life of someone''s session. In the application controller, I grab the data and store it like so: session[:foo] = @foo Now, whenever I need to access data about foo I don''t need to cause any DB io, I can just grab foo from the session (it''s very small fyi). Here''s what I
2006 Feb 22
5
Optional Include Relationship
I did some searches in the mailing list and on the web but I can''t seem to find the answer to this, but it''s pretty much a noob question. I have a Product object class Product < ActiveRecord::Base has_many :product_identifications has_one :product_identification_item_number has_one :product_identification_product_code end the product_identifications is using
2006 Sep 29
1
newbie Q: it won't display foreign keys...
I have two tables CREATE TABLE continents ( id int(11) NOT NULL auto_increment, name varchar(255) NOT NULL, PRIMARY KEY (id) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; CREATE TABLE countries ( id int(11) NOT NULL auto_increment, name varchar(255) NOT NULL, continent_id int(11) NOT NULL, PRIMARY KEY (id) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; I generate scaffolds for country and for
2006 May 16
1
saving a has_one association question
Hiall, Say I have class User has_one :community end class Community belongs_to :user end Will the following work and both save user and community if validation doesn''t fail? user = params[:user] user.community = params[:community] user.save Or do I have to do something like the following user = params[:user] if user.save user.community = params[:community] end to be on the
2008 Jan 08
0
Error in validation
I have the following model =========================== class SoftwareCi < ActiveRecord::Base has_one :ci, :as => :content has_one :primary_group validates_presence_of :name, :message => "can''t be empty" end The controller ================ def create @software_ci= SoftwareCi.new(params[:ci]) redirect_to :action => ''create_ui'' end The
2006 Apr 22
0
Is it possible to have one class containing tw
Hello fellow Rail-builders, Is it possible to declare one class that includes two polymorphic fields as such: class Mark < ActiveRecord::Base # attribute: value, :string belongs_to :markable, polymorphic => true end class Property < ActiveRecord::Base has_one :name, :as => :markable has_one :value, :as => :markable end ? Based on what I know of the underlying
2008 Sep 16
3
has_one :through eager-loading problem
I have a problem with the :include option in find for my has_one :through association. I have Users, Profiles and Customers, all connected to each other with a has_one :through => :membership association like this: class Profile < ActiveRecord::Base #could also be user or customer has_one :membership # i saw an acrticle of Ryan about has_one :through, there this would be has_many, is
2008 Feb 19
0
Issue with Observers and has_one association...
Hey Guys, I''m getting a peculiar bug working with Observers and has_one associations. When a has_one association is invoked by an Observer it always returns null. I looked in the development.log file and the SQL for the has_one association isn''t even being executed. On the other hand, when I replace the has_one association with just a hand crafted method, it does get called
2006 May 08
1
script/generate scaffold errors
Hi, I''m following the Agile Development With Rails book and having some trouble. Specifically, I''ve typed: % ruby script/generate scaffold Product Admin and received the following error: /usr/local//lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/core_ext/hash/keys.rb:27:in `symbolize_keys'': undefined method `to_sym'' for