Displaying 20 results from an estimated 45 matches for "state_ids".
Did you mean:
state_idx
2006 Jan 11
6
How to display the error messages from the controller
I have a wizard which consists of two pages. To keep 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"
2006 Jan 31
2
Relationship navigation issue
class Event < ActiveRecord::Base
belongs_to :venue
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.*
2012 May 28
4
How to load a selection list into the method new of a controller?
Hi friends!
I''m relatively new with Rails and I''m struggling for a long time with this
problem (it should have a pattern solution but until now I didn''t find it):
I have the following models: Institution, City, State and Country.
class Country < ActiveRecord::Base
has_many :states
has_many :cities, :through => :states
end
# == Schema Information
# Table
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
either.
This
2006 May 28
3
Validating Foreign Key
Howdy,
I''m a Rails beginner working on my first significant project with RoR.
I''m trying to figure out how to validate a 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
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 <
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'',
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
I''m completely new to Ruby and Rails and could use some help resolving
an issue. I have a list method that is supposed to show the titles and
states(status) of requests, but I get an error from this piece of code:
<td><%= 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
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
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
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
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
Here''s what I''ve got:
<% @fields.each do |field_name| %>
<tr>
<td>
<%= field_name.humanize %>
</td>
<td>
<% unless field_name =~ /_id$/ %>
<%= form.text_field field_name, :size => 40 %>
<% else %>
<%= select(:vendor,
field_name,
State.find(:all, :order
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
I have a model that has two properties that both come from the same
database table.
Let''s say I have a "Lead" model. This Lead has both 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".
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
Hi All,
I took this idea Christian Hellsten and Jarkko Laine''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
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