similar to: Validating collections

Displaying 20 results from an estimated 10000 matches similar to: "Validating collections"

2006 Apr 14
2
spot the error (I can''t, I''m new)
I have a form that I want to use to update multiple objects. In the controller, @grades = Grade.find(params[:grade].keys) @grades.each_with_index do |grade, i| grade.update_attribute(params[:grade][i]) end all_valid = @grades.inject(true) {|memo, c| c.valid? && memo } this doesn''t update the attributes as I would expect. (I would just use
2006 Jan 19
5
TIP: Using field_error_proc to add style attributes to form elements
I just put this up on the wiki, and thought I''d share in case it''s useful to anyone else. This is handy if you don?t want to wrap your input elements inside a div when an error occurs, but instead want to add some sort of CSS style to fields with errors: ActionView::Base.field_error_proc = Proc.new do |html_tag, instance| msg = instance.error_message error_style =
2009 Jun 28
2
validation error messages in Form - how to disable the ActionView::Base.field_error_proc ?
I wrote the following code in my form view : <li><label for="email">Email</label> <%= form.text_field :email, :size => "30" %> <span id=''email_error'' class=\''warning-text warning-text-indent\''><%= @user.errors.on(:email) %></span></li> the generated html code is the following : <span
2006 May 24
0
Problems validating form with collection_select
I have the following models: class Comandancia < ActiveRecord::Base has_many :elementos end class Elemento < ActiveRecord::Base belongs_to :comandancia validates_presence_of :nombre, :apellido_paterno, :apellido_materno, :comandancia end In the view for New Elemento I''m using <%= start_form_tag :action => ''create'' %> <%= render :partial =>
2007 Sep 21
1
Weird data from evalJSON
I am trying to have prototype perform a request and return to me a javascript object representing the json string returned by the request. I want to iterate over the contents to print each object in the json string. The value of transport.reponseText in onSuccess is what I would expect. But once I try to perform evalJSON() on this text it gives me a bunch of extra function()s when i try to
2006 Jun 12
0
Realtime form validation for forms containing collections
Hi, I''m successfully using the realtime_form_validation plugin from http://railsrtv.rubyforge.org/ However, my forms contain collections, as described in the AWDWR book. Basically my form looks like this. 2004 2005 2006 Question 1 12 13 15 Question 2 9 11 13 I have the following code to generate ids for my input fields.
2006 Jan 02
1
Dealing with collections of model objects
For an application I''m writing I have a model object, "Answer", many of which are associated with a "Request" object. A user will need to answer many questions, each of which is stored in an Answer object that is associated with their request (Request has many Answers). Is there an easy way to create and then validate each of these Answer objects? I basically want to
2006 Jun 17
0
Dynamic forms containing collections
Hiall, I have the following problem: I need to use forms containing collections (i will call them FCC), and I want to construct them dynamically, as I need to deal with quite large forms (more than 600 input fields). The variables @model_name and @field_name contain the proper model and field names as strings, which is enough for "normal" form input fields. (i.e. the "if
2006 Jul 21
5
How to display data using helpers and collections
## application_helper.rb def name_field(object, options = {} ) html = "" html << "Title : " + select(object, ''title'') html << "Given Names :" + text_field(object, ''given_names'' html << "Family Name :" + text_field(object, ''family_name'' html end ## index.rhtml <div
2005 Feb 05
4
Creating collections
I''m trying to create a form where a collection is created, using the example from the Rails 0.9.5 weblog posting: http://weblog.rubyonrails.com/archives/2005/01/26/rails-095-a-world-of- fixes-and-tweaks/ I''m having a bit of trouble. The controller currently looks like this: class StudentController < ApplicationController def new render_text @params.inspect
2008 Apr 22
1
Problem with Prototype 1.6.0.2, Opera 9 and Form.serialize()
Hello, following code fragment given: ~~~ function jsPostAppend(script, form_id) { if(form_id) //parameters=''&'' + $(form_id).serialize() // first flavour parameters=''&'' + Form.serialize($(form_id)) // second flavour [...] ~~~ This works perfect for FF2, IE7 and Safari3 (in both flavours). With Opera 9.x, I get the following javascript errors:
2008 Jul 06
1
ActionView::Base.field_error_proc not getting an error field
In my User form I have standard field to get user record attributes (first_name, last_name and email) I also have a select drop_down to choose a role from an array first_name, last_name and email are user record attributes, but I defined the role name as a virtual attribute validates_presence_of :email, :last_name attr_accessor :role_name validates_presence_of :role_name, :if =>
2006 Mar 10
4
validation is giving me heartburn
this one is killing me. all i want to do is validate the format of user-entered software versions. so in the model i have: validates_format_of :version, :message=>"Not valid version number." :with=>/[0-9]\.[0-9]{2}\.[0-9]{2}\.[0-9]{2}\.[0-9]{2}/ the form field is simply the scaffold form code: <p><label
2006 Mar 29
0
has_and_belongs_to_many and collections management
Sorry for the big post. I''m having a lot of confusion when trying to implement a simple model relationship that uses all the good things of ActiveRecord. I need to store some dinamic entries about knowledge of certain people on the database. A knowledge is measured with another table, with a range of possible values for a knowledge. This is a reduced schema of my database: create table
2006 Mar 16
0
validating presence of a tag
Hi, I''m using acts_as_taggable. I have a form that asks for a question and a tag for that question, something like: <% form_tag -%> <%= text_area("question", "question_text") %> <%= text_field("tag", "name") %> <%= submit_tag %> <% end_form_tag %> The question is one model. Tag is another. My problem is that I
2006 Apr 05
3
CRUD pattern for has_many relationships (forms containing collections)?
Hello folks! Beare with me for a second, while I explain my problem. Assuming we have the trivial model of class Author has_many :books end class Book end How do people go about creating the authors/edit and authors/new views if you want to be able to add and remove arbitrary amount of Books at Author creation and edit time? What I mean by this is that I go to
2005 Dec 29
2
validation highlighting on non-scaffold fields
Hi all, I''m new to rails. I have created a bunch of CRUD code using scaffolds. I had to add code to the default output to account for fields that establish the relationships between tables. Everything works well, including the validation of the fields I added. However, I can''t get the highlighting to work for my fields when they fail validation and the view is redisplayed.
2010 Dec 14
4
Custom form error messages
Hi, What do I have to override in order to be able to have the error message of each field in front of the input field? I haven''t been able to find anything similar on google. All I''ve found is how to override the container around the input field. ActionView::Base.field_error_proc = Proc.new { |html_tag, instance| "<span
2005 Mar 10
2
Newbie question - form validation
Hi, I am sorry for maybe stupid question. I am new in rails. I am trying to create very simple weblog systeme. I know threre are plenty of them, but It''s good to study. I create following rule in models/post.rb validates_length_of :header, :in => 3..50, :allow_nil => false, :message => "At least 3 characters" It''s working fine with default scaffolt add
2006 Feb 02
0
Validation fails with select option list
I have a form with some text_field and some drop down lists. <input id="student_fname" name="student[fname]" size="20" value="" type="text"> <input id="student_mname" name="student[mname]" size="20" value="" type="text"> <input id="student_lname"