similar to: model validates twice in tests, produces duplicate errors

Displaying 20 results from an estimated 100 matches similar to: "model validates twice in tests, produces duplicate errors"

2006 Jun 16
3
Does HABTM support non "id" FKs?
Quick question. Say I have a geographical database with counties and zip codes where counties have and belong to many zip codes. zip_codes (id, zip_code) counties (id, name) When I create the association table, the Rails way says to do the following: counties_zip_codes (county_id, zip_code_id). However, given that zip_codes.zip_code is itself a candidate key, I would much prefer to do the
2009 Apr 16
0
how to convert the find_by_sql code to the find code
I want to convert following query into pure ruby one i.e. by using find @us_state_sales=SalesReport.find_by_sql("SELECT z.state, sum(s.royalty_price) as royalty_price, sum(s.units) as units FROM sales_reports s, zip_codes z WHERE royalty_currency = ''USD'' && z.zip_code=s.postal_code GROUP BY z.state ORDER BY royalty_price desc LIMIT 10") i try something like
2009 Jun 23
2
syntax error, unexpected tINTEGER, expecting $end
Please help me solve the following error message: syntax error, unexpected tINTEGER, expecting $end I have this model: Code: 1. class GeoDatum < ActiveRecord::Base 2. end The database contains the table geo_data, which contains the zip_code column, filled with zip codes. I get the above error when searching for a zip code and the zip code exists in the table. Here is the
2006 Mar 21
2
Sorting by computed temporary field
Hey all, I''m rather new to Ruby and Rails (and not great with SQL), but I''m developing a ride sharing app and would like to be able to sort on something I don''t have stored. I have users, events, and rides, each of which has a zip code. Events have_many rides, and rides belong_to events. When an event is selected, I''d like to be able to show a list of
2008 Dec 23
1
aggregate / tranpose data
Dear R-Users, Suppose I have data in the following format: CODE_NAME ZIP_CODE John 12345 John 23456 John 34567 Jane 13242 Jane 22123 I want to transpose / convert it into: CODE_NAME ZIP_CODE John 12345,23456,34567 Jane 13242,22123 Any idea/pointer is appreciated.
2006 Oct 13
3
Validation errors in has_one/belongs_to relationships.
I have two objects, QuoteInput and Insured. QuoteInput has one Insured and Insured belongs to QuoteInput. I don''t understand what I''m seeing. I assign an Insured to a QuoteInput. The Insured object has invalid data. I call save! on the quote input. QuoteInput has no validations. I expect two things to happen - 1) an exception should be thrown, indicating that there was a
2013 Dec 10
2
form_tag + fields_for Rails 4
Hi There, I''m trying to user fields_for inside a form_tag, but i can''t catch it on my controller. I just take some html code off to makes it easy to read my view... i''m using campuses_path(current_church, @campus) instead form_for @campus, because my route is like resources :campuses, :path => ":church/campuses" <%= form_tag
2013 Feb 22
6
Samba 4 and freeradius
Hi, My goal is to make use of samba 4 and freeradius to authenticate user to use wifi network (WPA2 enterprise). The setup is to setup Samba 4.0.3 in machine A and setup freeradius in machine B. By reading: Document A: http://wiki.samba.org/index.php/Samba4/beyond Document B: https://wiki.samba.org/index.php/Samba4/HOWTO/Virtual_Private_Network Document C:
2012 Mar 22
1
Rspec not loading fixtures
I am taking over a code base and am trying to run the tests. I am somewhat new to RSpec so this might be a trivial problem. Basically I can tell that the fixtures are not getting loaded. All 100 tests fail with a similar error. But I don''t know why. Below is the code, with my narrative with *** before it... Can you see anything or give me a clue where to look. So far I am coming up
2009 Jul 31
2
Undefined method updated? for <model object>
Hi, I have two model say- ZipCode < ActiveRecord::Base belongs_to :state_provinces end StateProvince < ActiveRecord::Base has_many :zip_codes end if I do @zip_code.update_atribute(:city, "My City") its giving Undefined method updated? for StateProvince if I remove belongs_to specifier in ZipCode class then it work fine. Any alternate solution?? Thanks -- Regards, Himanshu
2007 Nov 03
3
Birthdate validation
Hello everyone, I''m almost cracking my head trying to do this birthdate validation. It turns out that I can only accept users with at least 18 years old and I''m trying to validate it writing this code on my user.rb fil at app/ models class User < ActiveRecord::Base validates_presence_of :full_name validates_presence_of :street_address validates_presence_of :city
2012 Sep 28
1
How to Include Associations in #as_json
Hi, Does anyone know how to include nested associations when overriding a model''s #as_json method? Below is my attempt to include direct and nested associations. NOTE: "office" is a direct association, "company" is nested association via "office". I''d like both included in the generated json output. def as_json(options={}) super(:include
2006 Dec 08
9
How to update partial attributes of a object from a form?
I have a user table, and it has forty columns, including name, gender, address, email, phone... So my @user object will have forty attributes. I divide these attributes into 4 groups... namely ''general info'', ''personal info'', ''contact info''... and I make separate forms to edit these 4 different group attributes. The problem is when I update
2006 Nov 07
1
reading VERY large binary files
Hello, I am trying to read in elements out of a very large binary file ... the total file is 4 gigs. I want to select rows out of the file, and the current procedure I run works but is prohibitively slow (takes more than a day to run and still won't complete). Is there any faster way to accomplish this? My current procedure looks like this: readHH <- function(file_name,
2023 Oct 24
1
by function does not separate output from function with mulliple parts
Colleagues, I have written an R function (see fully annotated code below), with which I want to process a dataframe within levels of the variable StepType. My program works, it processes the data within levels of StepType, but the usual headers that separate the output by levels of StepType are at the end of the listing rather than being used as separators, i.e. I get Regression results StepType
2007 Nov 14
0
Should receive field_for failing
I have a spec that''s not behaving as I''m thinking it should. Here''s the code: http://pastie.caboo.se/117931 it''s failing with: ActionView::TemplateError in ''customers/new should receive fields_for'' Mock ''ActionView::Base'' expected :form_for with ("address", #<Address id: nil, address1: "123 Main St.",
2008 Jan 29
0
ActionMailer calling shared methods
I''m trying to use a shared method from an ActionMailer template. The method was originally in ApplicationHelper, but I''ve also tried it in the base controller (application.rb), with and without helper_method. In all cases, I get an error undefined method `wgg_replace_crlf'' for #<ActionView::Base:0x324b230> Here is the relevant block of code from the email
2009 Oct 02
0
Problems with validates_uniqueness_of
Hi to everybody, well i recently became a RoR developer, web i was following the video class from Lynda, and i introduce more code in my aplicacion, my application is a music store web site, ok so i add the funcionality of add clients, for that i need from my client, his user and password, so it will be 1 user per client, for that reason i use at my model validates_uniqueness_of :user
2009 May 01
0
Graticule / acts_as_geocodable error?
Has anyone encountered this error using Graticule & acts_as_geocodable? ActiveRecord::UnknownAttributeError (unknown attribute: precision): (__DELEGATION__):2:in `__send__'' (__DELEGATION__):2:in `with_scope'' app/models/listing.rb:113:in `advanced_find'' ... Here is line 113 in listing.rb: published.find(:all, :origin => zip_code, :within =>
2006 Apr 26
5
Best way to split forms into steps?
I have a form with about 30+ fields, which the client is wanting to separate into 3 pages/steps - just wondering what is the best way to go about this, specifically remembering data entered, from one page to another, and making sure the various bits of data are validated correclty, error messages outputted etc etc... is there a best practice method for doing this? -- Posted via