similar to: stuck on a validates_presence_of unless issue

Displaying 20 results from an estimated 400 matches similar to: "stuck on a validates_presence_of unless issue"

2008 Feb 25
1
NoMethodError: undefined method `<=>' for :zip:Symbol
Long time programmer, but I just started learning RoR last week. I am going through some examples in the book "Ruby on Rails: Up and Running". The example I am on had me add a table to the database that looks like so: CREATE TABLE people ( `id` int(11) NOT NULL auto_increment, `type` varchar(20) default NULL, `name` varchar(20) default NULL, `email` varchar(30) default NULL,
2006 May 24
4
AR foreign key problem.
Hello Railslist, (I''m using RadRails 0.6.3 on Windows XP with Ruby 1.8.4, Rails 1.1 and SQLite3) I have two tables in the database: "locations" and "customers": customers.sql --- id INT PRIMARY KEY name VARCHAR 255 address VARCHAR 255 postal_code VARCHAR 255 city VARCHAR 255 --- locations.sql --- id INT PRIMARY KEY postal_code TEXT longitude FLOAT latitude FLOAT
2007 Mar 26
2
Issue generating XML with hyphenated element names
Hello... I''m trying to generate and XML file using .rxml and I''m having a problem with element names that contain a hyphen. Here is a chunk of the .rxml file: xml.instruct! :xml, :version=>"1.0" xml.properties do @properties.each do |p| xml.property do xml.location do xml.street-address(p.street_address) xml.city-name(p.city) .. end end end
2014 Feb 06
0
Array Confusion
I have the following instruction that returns an array that I'm quite confused about. I can't even read it. Can someone shed some light as to how to reach into this array of hashes (that's what I can see) to get the location lat and lon? res = Geocoder.search(addy1) This is the res: [#<Geocoder::Result::Google:0x007fb46c345e18
2008 Jun 18
1
Vpim gem
On Wed, Jun 18, 2008 at 6:32 AM, Joost Hietbrink <joost at joopp.com> wrote: > Hi Sam Roberts, > First of all. Thanks for the Vpim gem. We use it at www.yelloyello.com and > it works great. I''m glad to hear that. > We''ve only encountered the following error: > # NoMethodError (undefined method `to_str'' for []:Array): > # >
2012 Nov 29
2
[Rails 3.2] form_tag w :remote => true doesn't fire up the js format
I have a form_tag written like this : = form_tag search_backoffice_places_path, {:remote =>"true", :id => :searchplaceForm } do .. input fields = submit_tag t(:search) generated html is correct : <form accept-charset="UTF-8" action="/en/backoffice/places/search" data-remote="true" id="searchplaceForm" method="post"> ...
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
2009 Nov 06
0
Nested objects not propagating from view
I thought I had this fixed, but apparently not. It works okay from the console, but not from the view. I have the following: # partial schema create_table "users", :force => true do |t| t.string "login", :null => false t.string "first_name" t.string "last_name" t.string "email", :null => false
2012 May 04
3
Database schema question
Im setting up a very basic rails app and have a question about the needed migrations & associations. Basically, my app is an occasion reminder service that emails users when occasions that they select or input are coming up. Occasions will be selected from a checkbox type list or alternatively manually input by the user (name and date of the occasion). Users can have_many occassions.
2006 Apr 17
1
Autocompleter to read value from hidden field
I have an autocomplete field with road names (looking up in a database with approx. 100,000 road names). To limit the number of roads, i want an extra input field where to put postal code. I''m currently using <%= text_field_with_auto_complete %> for the field. What is the best way in Rails to intercept the Ajax call and send the value of the postal_code field? (I guess I could do
2006 Apr 23
2
Rails Recipes
Rails Recipes ... has got some very appetizing recipes. However, I have a hard time starting. For example, the very first recipe, InPlaceEditing, how and where do I run this code to create the table? Thanks! class AddContactsTable < ActiveRecord::Migration def self.up create_table :contacts do |t| t.column :name, :string t.column :email, :string t.column :phone,
2006 Oct 11
1
Polymorphic Validations
Hi Everyone, Ran into an interesting case last night, and I was hoping that someone on the list here could give me some guidance. I''ve got a Polymorphic association for Addresses (which can belong to two different models). The catch is, one model requires a strict, precise address, and the other only requires a City, State and Postal Code. I want to use :validates_presence_of :street,
2009 Jan 16
3
rspec model testing - test on user defined validation- How do I test that the create failed.
I''m new to rspec and looking for way to test a validation I added to a model. The test checks to see that if field1 has a value then field2 must be nil and vice versa. ------------------------------- When I did the rspec_scaffold it generated one test which worked before :each do @valid_attributes = { :field1 = "value for field1" :field2 = "value for
2008 Jul 06
1
GeoKit / Form Validation
I am new to rails and have been scouring the web for the past two days trying to figure out 2 things. 1) I am currently using a form with 2 models. The first is person, the second is address. I attempted to duplicate the two models on one form as seen in Advanced Rails Recipes and Railscasts, and they work fine - except when there are validation issues on the address piece it just returns saying
2008 Mar 19
2
Stub / Mock - A little guidance?
Hi there, I''m still trying to wrap my head around when to use a stub and a mock. If I understand this right, I should be using a ''mock'' when imitating an object, but not its behavior. I should be using a stub when I want to imitate the behavior of an object. Does that sound about right? With that said, I''m struggling a little trying to spec out this instance
2007 May 04
2
Custom Matcher and NAME NOT GENERATED annoyance
Hello RSpec users, Have been using RSpec since 0.8.2 (not too long ago, I must say). and been creating my custom matchers since was defined as "good practice". Also, auto-generated names for the examples is very helpful, I''m trying to take advantage of it. Since I often prior code/define all the "examples", I have created a few matchers to fulfill associations and
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
2006 Aug 10
4
exporting vcards from rails
i''m doing a site for someone that has a form set up to collect contact information from the user. i installed the vpim gem and was hoping to give my client a way to download all of the contact''s information as a vcard. using the examples, i was able to get it working in ruby, but i''m not quite sure how to generate and download a vcard on the fly. has anyone done
2011 Mar 10
4
Multi-model forms
Hi guys, I''m new to ruby and rails and I''m working on multi model forms, specifically 3. I''m using this http://guides.rubyonrails.org/getting_started.html as a start, and its got a 2 Model example but I cant seem to get the last one working. These are my models: Country name:string code:string (has_one :address) Address address_line1:string
2012 Nov 12
7
RSpec: controller POST create
Rails 3.1.3 rspec-rails (2.11.4) rspec 2.11.1 I am new to rspec. I don''t quite understand tests for POST create part. I have generated scaffold, and simultaneously it generated controller_spec.rb as well. it "assigns a newly created plan as @plan" do post :create, {:plan => valid_attributes}, valid_session assigns(:plan).should be_a(Plan)