search for: state_id

Displaying 20 results from an estimated 45 matches for "state_id".

Did you mean: pstate_id
2006 Jan 11
6
How to display the error messages from the controller
...p it simple let''s say that the first page asks the user to select a state from the drop down menu. In case the user doesn''t select any state, an error message needs to be displayed. Ideally I would like to do something like this. def new selected_value = params[:addevent][:state_id] if selected_value == "-1" errors.add(:state_id,"Please select a valid state") else # go to the next page end end But errors is not available in the controller. It''s available only in the model. I could use flash[:notice] but using errors wou...
2006 Jan 31
2
Relationship navigation issue
...belongs_to :category end class Venue < ActiveRecord::Base belongs_to :city end class City < ActiveRecord::Base belongs_to :state end I want to retrieve all event records belonging to a state. Coming from hibernate background I tried something like this: def self.list_for_a_state(state_id) find_by_sql(["select e.* from venues v, events e where v.city.state_id=? and e.venue_id = v.id",state_id]) end Error: Unknown table ''v.city'' in where clause How do I handle this case? Thanks. -------------- next part -------------- An HTML attachment was scrubbe...
2012 May 28
4
How to load a selection list into the method new of a controller?
...not null # nome :string(40) not null class City < ActiveRecord::Base has_many :institutions belongs_to :country belongs_to :state end # == Schema Information # Table name: cities # id :integer not null, primary key # country_id :integer not null # state_id :integer not null # nome :string(40) not null class Institution < ActiveRecord::Base belongs_to :city end # == Schema Information # Table name: institutions # id :integer not null, primary key # city_id :integer The table states is...
2006 Jul 14
20
Method for associated relationships
I have these tables set up like this: listings has_many :states <field>state_id [int] <other fields.... .............. .............> states belongs_to: listings <field>name <other fields.. ............... .................> In my view I have <%= listing.name %> have also tried listing.state_id.name , that didn''t seem to do the magic eithe...
2006 May 28
3
Validating Foreign Key
...you know, make sure the row actually exists.) However, validates_associated doesn''t seem to be what I want to use, nor does it work... -- BEGIN -- class City < ActiveRecord::Base has_many :schools belongs_to :state validates_presence_of :city_name validates_presence_of :state_id validates_associated :state end class State < ActiveRecord::Base has_many :cities validates_presence_of :long_name validates_presence_of :state_code validates_length_of :state_code, :is => 2 validates_uniqueness_of :state_code end -- END -- Regardless of all of that, my t...
2006 Mar 23
4
belongs_to more than one model
Suppose I have one table: states id statename And I have two other tables that contains states: houses id color state_id places id place_name state_id How would my model relationships look like? class State < ActiveRecord::Base belongs_to house belongs_to place end class House < ActiveRecord::Base has_one state end class Place < ActiveRecord::Base has_one state end Is that r...
2007 Aug 20
0
FormBuilder in rjs
I have a page, which renders a partial that contains a ''State'' drop down list. Upon change, it re-renders the ''City'' drop down, re- populating it based on selected state_id: Page: /customer/new.rhtml <% form_for :customer, :url => customers_path do |f| %> State: <%= f.collection_select :state_id, State.find(:all), ''id'', ''description'' %> <%= observe_field :customer_state_id, :url => search_cities_url, :with =&...
2006 May 22
15
collection_select default selected value
Hiall, Unfortunately I just can''t find out how to setup a default selected value when using collection_select. My call is like so: <%= collection_select(:consultant, :lastname, @consultants, :id, :lastname, { :selected => @current_consultant.id } ) %> which is not working, I debugged so far that I know that @current_consultant.id contains the correct value. Any tips? cheers
2006 Oct 25
12
NameError, uninitialized constant States
...%= change.states.state %></td> The error is: c:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:100:in `const_missing'': uninitialized constant States The states table contains an id and state field. The changes table holds a foreign key named state_id that references the states table. I want this code to simply display the text from the state field for the specified change request. Can anyone tell me what''s wrong? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google...
2009 Nov 06
0
Nested objects not propagating from view
...iztype_id" t.datetime "created_at" t.datetime "updated_at" end create_table "addresses", :force => true do |t| t.string "street_address1" t.string "street_address2" t.string "city" t.integer "state_id" t.integer "zipcode" t.integer "plus4" t.datetime "created_at" t.datetime "updated_at" end # relevant models class User < ActiveRecord::Base belongs_to :contact has_many :properties has_many :notes, :through =>...
2006 Mar 11
0
Using :joins - How to help Rails populate a list of records from a complex join
Hi, Due to some performance issues, I want to use a custom query for a find method: def find_in_state(state) State.find :all, :limit => 10, :conditions => [''s.id = ? AND '' + ''s.id = c.state_id AND c.state_id = ? AND '' + ''c.id = col.county_id AND '' + ''s.id = l.state_id AND l.state_id = ? AND '' + ''g.id = l.group_id AND '' +...
2012 Mar 22
1
Rspec not loading fixtures
...b51b237344fe0e72539af0cac7197f094a5e933ffacf6e7fa612363c5933f520710c6427ac31fc4c68a2d7bb48eae601c74b96e7838f9ca1a0740b67576a" 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:...
2006 Apr 12
22
Dynamic Select Box
Hi, I''m new to rails/ruby having come from PHP and am just starting to get my head round how easy it can be :) However, can anyone point me in the right direction for dynamicaly updating a select box based upon the choice of a previous select box, without a page refresh. Any and all help greatly appreciated. Thanks -- Posted via http://www.ruby-forum.com/.
2006 Jun 26
2
DRY up selects in view
...:vendor, field_name, State.find(:all, :order => ''name'').collect {|p| [ p.name, p.id ] }, :selected => @vendor.state.id ) %> <% end %> </td> </tr> </end> Right now this works great if I only have "state_id" as the related field_name. I could repeat this for every field_name ending in "_id", but that''s not DRY. I''d like to allow this to work for any field_names ending in "_id" but I need to use the field_name without the "_id" and capitalized a...
2006 Aug 13
1
select include_blank true
Is there any way to display a default message value ''Select'' rather tha an empty value when using this option ? kad -- Posted via http://www.ruby-forum.com/.
2006 Apr 25
4
belongs_to :through
belongs_to :through Why is that not possible? We should have: Street belongs_to :city belongs_to :country, :through => :city -- Posted via http://www.ruby-forum.com/.
2007 Jan 15
1
Using One Lookup Table for Multiple Model Properties
...h a contact "State" (as in Colorado, Arkansas, etc.) and a "Property State" where the house he''s looking to refinance is located. Both of these should obviously be objects of the type "state". I''m running into trouble trying to put both the property_state_id and state_id in the object. Do I need to create a second model for PropertyState and just point it at the same database table? That seems a little messy when PropertyState and State are both basically State objects. I hope this is clear (as mud probably). Thanks in advance. Justin --~--~-----...
2006 Mar 28
2
In_place_editor_field throws error ...
I receive the following error: Called id for nil, which would mistakenly be 4 -- if you really wanted the id of nil, use object_id when trying to use the in_place_editor_field tag: <% for employee in @employees %> <%= in_place_editor_field :employee, employee.fname %> <% end %> My model is called Employee and is being populated from a controller method employees_list:
2007 Oct 26
1
Custom method in Application Controller
...9;s "Beginning Ruby on Rails E-Commerce". Here is the situation. I will be using the "options_from_collection_for_select" and "collection_select" form helper methods in my view to render drop-down selection lists for City and State that have corresponding city_id and state_id foreign key references in my address model/table. In Chapter 3 of this book, the authors suggesting using a private method in the address controller (contrived) called "load_data" which looks something like this: def load_data @cities = City.find(:all) @states = State.find(:all) end Th...
2006 Jun 13
8
Joins or relationships ?
I have a table called Post (not the actual name) where users input various piece of information, Most of the input is done by dynamic select''s (drop downs). As an example: User would choose Field: Input: Values that go into Post table Category Full Time 2 Length 45 Days 4 State