similar to: Validating two models from one form

Displaying 20 results from an estimated 3000 matches similar to: "Validating two models from one form"

2006 Mar 25
7
Overriding <div class="fieldWithErrors">
Does anyone know how to override the <div class="fieldWithErrors"> behaviour when a form field is incorrect? Thanks, Dan
2006 Jul 20
7
How do you use :message with validation?
If I do validates_uniqueness_of :name, :message => "It''s not uniqueeee!!!" then how do I have it display that message when the check fails? -Ben Lisbakken -- Posted via http://www.ruby-forum.com/.
2006 Mar 01
5
scaffold.css and Rails tutorial problem
In iteration D.1 on page 109 I am not getting a styled error message box displayed at the top of the checkout as described in the tutorial and I cannot seem to discover where I have erred. The scaffold.css is copied from the pragmatic programmers site: #-------------------------------------------------------------------- $ cat public/stylesheets/scaffold.css body { background-color: #fff;
2005 Dec 16
12
validates_presence_of not working
Hi, I''m new to ruby and rails. I just created a simple update page and the update works fine if all form fields are filled in. However there is one field that should never be allowed to be blank. So I put this in my model: class Topic < ActiveRecord::Base validates_presence_of :dr_title validates_length_of :dr_title, :minimum => 1 So, when I submit the form with a blank
2006 Jul 12
0
Give form elements "fieldWithErrors" class in non-std. way?
All, I want to know how to force an element of my model to be invalid, but not generate any message for it, so that the corresponding form field on a form will show up with the ''fieldWithErrors'' class. I have some checkboxes on my RHTML form, and they are generated with this code <%= check_box_tag("current_job[target_list_ids][]"...etc. %> target_list_ids
2006 Aug 18
0
AJAX question
Dear all, Help me get a simple AJAX behavior right. I know zero AJAX, thus please advice. Below is a simplification of the real code and I hope I can describe my intention clearly. class StoreController < ApplicationController def show_cart @cart = Cart.new @new_item = CartItem.new end def add_item @new_item = CartItem.new(params[:new_item]) if
2006 Aug 18
0
Simple AJAX question
Dear all, Help me get a simple AJAX behavior right. I know zero AJAX, thus please advice. Below is a simplification of the real code and I hope I can describe my intention clearly. class StoreController < ApplicationController def show_cart @cart = Cart.new @new_item = CartItem.new end def add_item @new_item = CartItem.new(params[:new_item]) if @new_item.valid?
2007 Apr 09
4
How do i switch off error wrapping for a specific field?
Hi, i have some issues with the default rails error wrapping. It wraps errors in a div with class ''fieldsWithError'', which is not good practice in my eyes. Adding a class ''error'' to the field would be much nicer. My solution to the problem: build your own FormBuilder. Funny enough, i found no (nice) possibility to switch error wrapping off while using the
2006 Jul 29
3
Validating two models
Hi, I have a model Account wich "has_one" model called UserData. Both models use validation. # Model contains user name, email etc. class Account < ActiveRecord::Base has_one :user_data, :foreign_key => "user_id" validates_presence_of :email end # Model contains firstname, lastname etc. class UserData < ActiveRecord::Base
2007 Nov 27
1
O/T div.fieldWithErrors styling
this is kinda trivial but I''m anal and it bugs me :) whenever there''s a error in the form the error field is wrapped with <div class="fieldWithErrors"> </div> this throws my form''s styling off because it puts too much space b/t fields and worse makes the form as wide as possible. How do I fix this? I''ve tried div.fieldWithErrors {
2005 Aug 19
1
css style fieldWithErrors when using tables
I''ve run across something that I''m not sure how to fix. This is with MSIE, Firefox doesn''t seem to have the same problem. When rails displays form fields in error using the css element fieldWithErrors, and the form field is enclosed in a table data tag, the entire background of the table data element is set to red instead of just the border of the form element.
2006 Oct 04
0
Displaying validates_acceptance_of Errors In A Check Box
Hello, I am having trouble displaying a check box which must be checked but hasn''t been. I would like it to be highlighted as in a scaffolded view but the hidden check box field which is generated by the check_box helper is also highlighted, and the text next to it loses its styling. My code follows. Should I get cleverer with the CSS or write my own check_box helper which
2009 Feb 24
4
Cannot pass id field to ActiveRecord
Dear all I have a dummy question. The model code as follow: class User < ActiveRecord::Base set_primary_key "username" end In script/console user = {:username => "123", :display_name => "345"} => {:username=>"123", :display_name=>"345"} a = User.new(user) => #<User username: nil, display_name: "345">
2007 Jan 13
1
fieldWithErrors - does not work
What conditions must be met for ''fieldWithErrors'' automatic wrapping? <% remote_form_for( :subscriber, :update => ''subscription'', :url => {:controller => ''subscribers'', :action => ''subscribe''} ) do |form| %> <p> <%= form.text_field
2006 Feb 17
0
Validation highlighin errors?
hi guys, i am having two problems with validation, one i cannot clear the errors in error_messages_for i have tried errors.clear with no joy the second problem is i cannot seem to highlight the offending fields looking at the code returned to the client there is no div tag with the fieldwitherrors or any reference for it. hope you can help if you wanna see my code its posted here
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> <%
2007 Dec 05
5
Active Record, Migration, and Translation
Hi, I think the columns and table in migration should be able to have an optional "display_name" set manually. Something like: create_table :people, {display_name => "Personne"} do |t| t.column :first_name :string, :display_name => "Prénom". end Let me explain my point of view: Rails is a framework made to write programs in English. You see it when you
2007 Nov 03
2
Service.services bug (pure Ruby version)
Hi all, I''ve hit a curious bug in the Service.services method. This is in the pure Ruby version in CVS. Check it out and run this snippet: Service.services{ |s| p s.service_name p s.display_name } That will segfault after about 14 entries for me. It appears to be a problem with memcpy on line 658, but I couldn''t tell you why. The interesting thing is that the more I
2005 Dec 19
7
Error handling!
Hello all, I''m in the beginning states of learning ruby on rails development and have got to a part where I''m a little stuck! Basically writing a simple blog application, just to try something completely different! ;-) I have a page which displays the current blog entry, it''s comments and at the bottom of the page, a form to add a comment. So far, so good.
2006 Mar 20
5
Wrap error_messages_for() call when no instance var present
I am trying to put some smarts around a call to <%= error_messages_for %> so that when I first come into this page i.e. when my instance variable @target_list has not been defined yet, the page doesn''t break. I''m doing this: <% if @target_list? %> <%= error_messages_for ''target_list'' %> <% end %> I get a syntax error on line 1.