is it a copy paste error or are
001_create_cities.rb
and
002_create_states.rb
equal ?
marcel
On 28 Mai, 09:21, "naga anusha"
<naga.anu...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:> 002_create_states.rb
>
> class CreateCities < ActiveRecord::Migration
> def self.up
> create_table :cities do |t|
> t.column :state_id, :integer
> t.column :city_name, :string
> end
> end
>
> def self.down
> drop_table :cities
> end
> end
>
> 001_create_cities.rb
>
> class CreateCities < ActiveRecord::Migration
> def self.up
> create_table :cities do |t|
> t.column :state_id, :integer
> t.column :city_name, :string
> end
> end
>
> def self.down
> drop_table :cities
> end
> end
>
> index.rhtml
>
> <%= javascript_include_tag "prototype" %>
>
> state
> <select name="state_id" id="state_id">
> <option value="">Select state</option>
> <% @states.each do |state| %>
> <option value="<%= state.id %>"><%=
state.state_name %></option>
> <% end %>
> </select>
> <br>
> city
> <div id="city_id_container">
> <select id="city_id">
> <option value="">cities</option>
> </select>
> </div>
>
> <%= observe_field(:state_id,
> :update => "city_id_container",
> :url => { :action => :index},
> :with => "''state_id=''+value") %>
>
> admin_controller.rb
>
> class AdminController < ApplicationController
> def index
> @cities = City.find_all_by_state_id(@params[":state_id"])
> @html = "<select id=''city_id''
name=''city_id''>"
> @html += "<option value="">No
city</option>"
> @cities.each do |@city|
> @html += "<option
value=...@city.id}''>#...@city.city_name}</option>"
> end
> @html += "</select>"
> @states = State.find(:all)
> end
> end
>
> state.rb
>
> class State < ActiveRecord::Base
> has_many :cities
> end
>
> city.rb
>
> class City < ActiveRecord::Base
> belongs_to :states
> end
>
> can u jst tell me how can i get the values into the 2nd drop down
> list...plss
--~--~---------~--~----~------------~-------~--~----~
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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---