similar to: Form question

Displaying 20 results from an estimated 10000 matches similar to: "Form question"

2006 Mar 25
3
validates_presence_of validation order?
I have a form with 3 fields: user_id, email and password. All 3 fields are required, so I have a "validates_presence_of :user_id, :email, :password" in my model. Works, but the validation errors show up in a different order than I specificed in the validates_presence_of statement. Is there a way to specify the order in which the validations (and corresponding error messages) should
2006 Jun 13
2
Custom Primary Key, Using Primary Key in Form "gives before_type_cast" error?
Hi guys, I''ve got a problem here which i need help from the pro''s in this mailing list I have a legacy app where the User table has a custom structure where "User_id" (username) is the primary key as well as the username used to log in User.rb (model) class User < ActiveRecord::Base set_table_name "cmf901" set_primary_key "user_id" end
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
2010 Jun 08
9
[Rails Heroku] Problem with saving object (on heroku hosting)
Hi All, I have some strange problem which appears only on heroku hosting 2.3.5 default stack (not on my local computer) I have some models. Here they are: class Contact < ActiveRecord::Base belongs_to :user belongs_to :type, :class_name => "ContactType", :foreign_key => "type_id" validates_presence_of :name, :on => :create, :message =>
2005 Oct 17
0
acts_as_taggable and per-user tags
I''m trying to add per-user tags to a simple app built atop the tiny_file example code, as follows: ------------------------------------------------------------------------------------------------- sqlite> .schema CREATE TABLE resources ( id INTEGER PRIMARY KEY, filename VARCHAR(255), user_id integer ); CREATE TABLE ''tags'' ( ''id'' INTEGER
2006 Jul 27
2
setting initial text field values in a form
Hi, I am trying to create a basic form in which I want one of the fields initialized before displaying it. My code (in a view) is as follows: <% if ( session[:user_id] != nil ) then logged_in_user = User.find(session[:user_id]) end %> <% form_for :suggestion do |form| %> <label for="suggestion_title">Topic:</label><br/> <%=
2009 Jul 04
9
prevent orphan records
If I have belongs_to :user Do I need to have validates_presence_of :user_id ? Does Rails validate the presence of :user_id automatically if I have belongs_to :user? In other words, does Rails prevent against creating orphan records that belong to non-existent users? Thanks. -- Posted via http://www.ruby-forum.com/.
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
2011 Feb 26
1
How to manage the form of a model that has two foreign keys
Hi, Basically I have two models: User and Godfather. The godfather table has three columns: - user_id (FK --> User) - user_godfather_id (FK --> User) - description (text) Inside each model class, I am adding the following associations: class User < ActiveRecord::Base has_many :godfathers # for user_id has_many :godfathers, :foreign_key =>
2006 Jun 14
0
Custom Primary Key, Using Primary Key in Form gives "before_type_cast" error?
Hi guys, I''ve got a problem here which i need help from the pro''s in this mailing list I have a legacy app where the User table has a custom structure where "User_id" (username) is the primary key as well as the username used to log in User.rb (model) class User < ActiveRecord::Base set_table_name "cmf901" set_primary_key "user_id" end
2007 Jan 01
5
Validations based on associations
My model is very simple, it''s mostly just a join table that represents which tournaments a user has registered for. class Registration < ActiveRecord::Base belongs_to :user belongs_to :tournament validates_presence_of :user_id, :tournament_id validates_uniqueness_of :user_id, :scope => :tournament_id end the validates_uniqueness checks to make sure there''s no
2006 May 23
1
Validating a required relationship.
Hello, I''m not sure if I''m missing something blindingly obvious here. All the relationships that Rails comes with assume 0..n, yes? It''s not a strict 1 to 1 or 1 to n because it''s optional. My question is this - What is the best way to implement a required relationship? For example, if I require that a comment is made by a user (a user has many
2009 Sep 21
0
Polymorphic form
I have two partials to deal with contact information. The Contact information uses single-table polymorphism. I want to be able to use save on Contact and set ''type'' manually, based on the type of form the user is filling in. This is saved as the value on a hidden field. class Contact belongs_to :person acts_as_list :scope => :person validates_presence_of :type
2006 Apr 10
3
Problems with multiple ActiveRecords and Validations
Hi all, I am a RoR newbie and have the following scenario set up: There are 2 ActiveRecords involved, the first one being "User", the second one being "Visibility". The corresponding users table holds address informations regarding a User. The visibilities table holds visibility settings for the individual columns of the users table (i.e. firstname, lastname, country
2012 Aug 17
3
Rails doesn't validate create_model or build_model (has_one association)
I''ve got User has_one Shop. Rails is not validating when I tried create_shop or build_shop, neither in the browser nor the rails console. My code: class Shop < ActiveRecord::Base attr_protected :user_id belongs_to :user validates_presence_of :name, :primary_address, :city, :country_code, :currency end class ShopsController < ApplicationController before_filter
2011 May 16
2
Cannot get multipart => true , running well in my form when using remote => true
I have a simple form , with a file field = form_for (Clip.new), :html => {:multipart => true} , :remote => true , do |f| = f.hidden_field :user_id, {:value => current_user.id} = f.text_field :name = f.text_area :description = f.file_field :image = f.submit I18n.t(:add) generating the html code <form accept-charset="UTF-8"
2006 Jan 22
2
acts_as_taggable: weird SQL problem with untagging
Setup as follows: class Resource < ActiveRecord::Base belongs_to :user validates_presence_of :filename validates_uniqueness_of :filename, :scope => "user_id", :message => "already exists, try uploading another file or deleting first." acts_as_taggable :join_class_name => ''TagResource''
2006 Mar 02
8
User Authentication
I''m trying to create a simple authentication system but am failing miserably. I''m (sort of) following the "Logging In" chapter of the Agile book. Ideally, any access to http://example.com/publish (and any of its subdirectories) should redirect to http:/example.com/publish/login when there is no valid session user_id. Code so far:
2006 Jul 04
1
LoginGenerator Problem
I am trying to make a barebones login system based on this example (which in turn is just standard RoR login) but when I enter a user name and password, it says the login is unsuccessful every time. I am not sure where I am going wrong. Here is all relevent information CREATE TABLE `users` ( `id` int(6) unsigned NOT NULL auto_increment, `login` varchar(20) NOT NULL default
2006 Jun 20
1
Possible to check if form field is required?
Hi list, is it possible to check if form field will be required when form is submitted (through validates_presence_of or some other validates_* method)? I could do this manually but it doesn''t seems to me very DRY. For example, I would like to be able to dynamically add asterisk with some helper method if city is required here: City*: <%= text_field