search for: zip_cod

Displaying 20 results from an estimated 24 matches for "zip_cod".

Did you mean: zip_code
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 following: counties_zip_codes (county_id...
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 this @us_state_sales1=SalesReport.find(:all, :select=>" zip_codes.state, sum(sales_reports.royalty_price) as ro...
2006 Mar 21
2
Sorting by computed temporary field
...dds a new @distance member element and sorts the new collection. Would something like this work? def find_and_sort(event_id) @rides = Ride.find(:all, :conditions => {"event_id = ?", event_id})" for ride in @rides ride.newdistance = distance_between_zips(session[:user].zip_code, Event.find(event_id).zip_code); end uhm.... sort @rides by newdistance end What if I want to also remove items from @rides before they are displayed if that newdistance is too large or some other condition? uhm... I''m stumped, I guess. That''s why I''m her...
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/pointe...
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 console output: >> GeoDatum.find_by_zip_code(95035) SyntaxError: compile error /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/ active...
2006 Oct 13
3
Validation errors in has_one/belongs_to relationships.
...bject. In script/console I see: >> ins = Insured.new => #<Insured:0x37345e0 @new_record=true, @attributes={"city"=>"", "address1"=>"" , "name"=>"", "updated_at"=>nil, "address2"=>nil, "zip_code"=>"", "dba_name"=>ni l, "quote_input_id"=>nil, "created_at"=>nil, "state"=>""}> >> ins.save! ActiveRecord::RecordInvalid: Validation failed: Name can''t be blank, Zip code co de is invalid f...
2013 Dec 10
2
form_tag + fields_for Rails 4
...rea :campus, :description %> > > <%= fields_for :addresses do |b| %> > <%= b.text_field :street %> > <%= b.text_field :street2 %> > <%= b.text_field :city %> > <%= b.text_field :state %> > <%= b.text_field :zip_code %> > <% end %> > > <input type=''submit'' value=''Save'' > > <% end %> my controller > class CampusesController < ApplicationController > def new > @campus = Campus.new > end > > def crea...
2006 Apr 04
3
model validates twice in tests, produces duplicate errors
...o execute twice, and produce duplicate error messages. This is making my tests fail (because I''m checking for the number of errors that I expect). In the web browser, only one error message is displayed. Anyone know what the cause of this could be? The Model: validates_length_of :zip_code, :is => 5, :allow_nil => true The Unit Test: def test_create_user_with_invalid_zip_code @u = User.new( :password => ''asecurepassword'', :password_confirmation => ''asecurepassword'', :display_name => ''invalid zip...
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 --~--~---------~--~----~------------~-------~--~-...
2012 Mar 22
1
Rspec not loading fixtures
...72539af0cac7197f094a5e933ffacf6e7fa612363c5933f520710c6427ac31fc4c68a2d7bb48eae601c74b96e7838f9ca1a0740b67576a" password_salt: "Y4PPzYx2ert3vC0OhEMo" name: Rocky organization: Rock The Vote url: http://rockthevote.com address: 123 Wherever city: Washington state_id: 9 zip_code: 20001 phone: 555-555-1234 survey_question_1_en: "What school did you go to?" survey_question_2_en: "What is your favorite musical group?" created_at: <%= Time.now %> updated_at: <%= Time.now %> # TODO: remove partner 2 in production partner: id: 2 use...
2012 Sep 28
1
How to Include Associations in #as_json
.... 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 => [{:office => {:only => [:company, :street, :city, :state, :zip_code]}}]) end Thanks. -Ari -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To un...
2006 Dec 08
9
How to update partial attributes of a object from a form?
...hash only contains partial attributes that @user has, so this can''t work. now, i use @user.update_attribute(:address, params[:user][:address]) @user.update_attribute(:city, params[:user][:city]) @user.update_attribute(:state, params[:user][:state]) @user.update_attribute(:zip_code, params[:user][:zip_code]) @user.update_attribute(:country, params[:user][:country]) @user.update_attribute(:phone, params[:user][:phone]) @user.update_attribute(:phone_alt, params[:user][:phone_alt]) which seem like a mess. any other solution? -- Posted via http://www.ruby-forum.co...
2006 Nov 07
1
reading VERY large binary files
...tran$total_dollars <- readBin(incon,integer(),1,size=4) tran$total_items <- readBin(incon,integer(),1,size=4) tran$order_id <- readBin(incon,integer(),1,size=4) tran$txn_type <- readChar(incon,1) tran$gender <- readChar(incon,1) tran$zip_code <- readChar(incon,5) tran$region_code <- readChar(incon,1) tran$county_code <- readChar(incon,1) tran$state_abbrev <- readChar(incon,2) tran$channel_code <- readChar(incon,1) tran$source_code <- readChar(incon,20) tran$payment...
2007 Nov 03
3
Birthdate validation
...;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 validates_presence_of :state validates_presence_of :country validates_presence_of :zip_code validates_numericality_of :zip_code, :message => "must contain only numbers." validates_presence_of :phone validates_numericality_of :phone, :message => "must contain only numbers." validates_presence_of :email validates_format_of :email, :with => /^([^@\s]+)@((?:...
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
2006 Mar 14
5
Column aliasing in ActiveRecord?
Anybody know of a way to alias a column in ActiveRecord such that you could reference it via a different symbol in your view for view purposes? Like my column is named X but I want to display it as Y and maybe I have an accessor named Y set up on the model so that when I "call" Y from the view (and controller?) I''m actually manipulating the column X? Hope that makes sense.
2007 Nov 14
0
Should receive field_for failing
...Error in ''customers/new should receive fields_for'' Mock ''ActionView::Base'' expected :form_for with ("address", #<Address id: nil, address1: "123 Main St.", address2: "PO Box 9403", city: "Anytown", state: "FL", zip_code: "12345">) but received it with (:customer, #<Customer:0x..fdb9ec5fe @name="Customer_1000">, {:url=>"/customers"}) Since the specs don''t seem to follow subsequent render calls, is there a way to verify that addresses/_form.html.haml is being call...
2008 Jan 29
0
ActionMailer calling shared methods
...#{@order.address.addressee}<br />" + "#{@order.address.address_1}<br />" + (@order.address.address_2.blank? ? '''' : "# {@order.address.address_2}<br />") + "#{@order.address.city}, #{@order.address.state} # {@order.address.zip_code}" + (@order.address.plus_four.blank? ? '''' : "-# {@order.address.plus_four}") end %> I have also tried prefacing the method call with ApplicationHelper::, but that didn''t work either. How does one use shared methods in email templates? Pea...
2008 May 05
0
uses_connection plugin
...ase and use the table thereā€¦ class ZipCode < ActiveRecord::Base # Uses the ''shared'' database in all environments uses_connection :shared, :in => :all end ... and the next time you do ZipCode.find(:first) or any other interaction with the ZipCode model it will use the zip_codes table in your shared database. Where to get it: =========== GitHb: http://github.com/railsfreaks/uses_connection More info: http://www.railsfreaks.com/2008/5/2/introducing-the-uses_connection-rails-plugin -- Thiago Jackiw http://www.railsfreaks.com --~--~---------~--~----~------------~-------~...
2009 May 01
0
Graticule / acts_as_geocodable error?
...le? 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 => miles, :conditions => [conditions.join(" AND "), args, args], :page => {:size => 10, :current => (page || '''')}, :order => ''distance ASC'') The only mention of ''precision'' is in my schema:...