search for: city_id

Displaying 20 results from an estimated 22 matches for "city_id".

2011 Apr 08
3
Ruby on rails migration problem
Hello all, I have created a migration add_details _to users ... ( city_id , profession ) and then migrated it.. when i use params[:user] to update the database by taking user inputs from forms in views, it is not updating the database for these city_id and profession... ( not changing from null ) if add validation for presence of city_id .. it is giving the error "...
2006 Jul 25
6
form and pagination question
Hello, How do I get params from a form to use with a paginator? debug(params) shows this city: !map:HashWithIndifferentAccess id: "1" but in my controller, when I try to use @hotel_pages = Paginator.new self, Hotel.count(:conditions => "hotels.city_id = params[:city][:id]"), 3, @params[''page''] it doesn''t work. I suppose it''s a simple syntax error but have no idea to fix it. Thanks for your help! -- Posted via http://www.ruby-forum.com/.
2006 Aug 16
8
Multiple (AJAX) Observers on the Same Field and MSIE
I have been using multiple observers, i.e., observe_field(), on the same input field and relying on them to execute in the same order that they appear in the page. This has been working fine in FireFox, but it does not seem to work in MSIE; the requests come in and are processed in a different order. Now, I''ve always been a little hesitant about using this technique, but it always
2006 Aug 16
0
Multiple observer
...%> <option value="<%= state.id %>"> <%= state.state_name %> </option> <% end %> </select> </td> <td valign="top" align="left"> <div id="city_container"> <select id="city_id" name="city_id" disabled="disabled"> <option value="">Select City</option> </select> </div> <%= observe_field("state[id]", :update => "city_container", :url => { :action...
2006 Aug 17
0
AJAX - Having Multiple SELECT (Drop Down), and dependency
...%> <option value="<%= state.id %>"> <%= state.state_name %> </option> <% end %> </select> </td> <td valign="top" align="left"> <div id="city_container"> <select id="city_id" name="city_id" disabled="disabled"> <option value="">Select City</option> </select> </div> <%= observe_field("state[id]", :update => "city_container", :url => { :action...
2008 Jul 07
1
Non model cascading selects
In my model I have a city_id. ON the form I am using a cascading select to select the state, which then does a remote_submit to get the list of cities (and hence the city_id) for the selected state. The problem that I am having is that if I make a selection, hit SUBMIT and validation fails, the original selected state/city i...
2006 Mar 22
4
Newbie - populating select list from db
Can''t seem to find an example of this anywhere - how do I populate a select list in a form from a database? I have a form to create a new task. The task is for a client, so there should be a select list populated from my clients table. I thought this would work: <%= select ''task'', ''client_id'', Client.find_all, "id", "name"
2008 May 07
1
Assigning to the foreign key on a belongs_to association
...he associated object (or mark a previously loaded one as stale) until you explicitly save or reload it. Let''s say we have a Company model, which belongs_to :city : >> torchbox = Company.find_by_name(''Torchbox'') => #<Company id: 1, name: "Torchbox", city_id: 1> >> torchbox.city => #<City id: 1, name: "Oxford"> >> torchbox.city_id = 2 => 2 >> torchbox.city => #<City id: 1, name: "Oxford"> (Would have expected City id: 2 to be returned here...) I''ve come up with a 6-line patch (see...
2007 Aug 20
0
FormBuilder in rjs
...lt;.div id=''state_div''><%= render :partial => ''city/list'', :object => [], :locals => { :f => f } %> <% end %> class CustomerController... def create @customer = Customer.create params[:customer] # => { :state_id => X, :city_id => Y } ... end end Partial: /city/_list.rhtml City: <%= f.collection_select :city_id, list, ''id'', ''name'' %> class CityController... def search @cities = City.find :all, :conditions => params[:search] # => { :state_id => X } e...
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.*
2006 Apr 04
4
Find records based on associated table''s colums
Hello, Let''s say I have a model for a "house". Each house has_a "city", which in turn has_a "state" which in turn has_a "country". The objective is to retrieve all houses in a given state, say "Massachusetts". Being new to Ruby on Rails what I like is that things that should be simple usually are simple, and since we have easy access to
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/.
2006 May 18
3
populating array of text_fields from an array of model objects
...; So I can post from this form to an action and I receive the following: Parameters: { performance"=>{"0"=>{"city"=>"Toronto", "time"=>"", "date"=>"", "venue"=>"The Opera House", "city_id"=>""}, "1"=>{"city"=>"Toronto", "time"=>"", "date"=>"", "venue"=>"The Social", "city_id"=>""}, "2"=>{"city"=>"", &quo...
2008 Dec 05
1
Question About Rails.cache and find method.
...st time I hit the DB but the next 1000 times I get the result from memory. Great. But most of the calls to city are not City.find(1) but @user.city.name where Rails does not use the fetch but queries the DB again... which makes sense but not exactly what I want it to do. I can do City.find(@user.city_id) but that is ugly. So my question to you guys. What are the smart people doing? What is the right way to do this? I look forward to getting feedback! :-) -- John Kopanas john-Iau1QiYlxLpBDgjK7y7TUQ@public.gmane.org Blog: http://www.kopanas.com Conference: http://www.cusec.net Twits: http://w...
2010 Feb 03
4
customizing validation msg
Hi, i am using the default validation of RoR how i will customize them i dont want to display the default message but i want to print the message i want like for city_id the default message is "City can''t be blank" i want this message as "Please enter city" Regards -- 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-/J...
2012 May 28
4
How to load a selection list into the method new of a controller?
...ountry_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 pre-loaded with all Brazil''s states (seed): State.create!(country_id: Country.find(:first, conditions: "sigla = ''ZZ''").id, nome: ''desconhecido'', sigla: ''ZZ'') State.create!(country_id:...
2007 Oct 26
1
Custom method in Application Controller
...aine''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(...
2013 Apr 02
4
gmaps4rails: undefined method `model_name' for NilClass:Class
Hi All, just in a spot of bother with this gem, I am trying to create a new location and get the above msg. here is my controller: class LocationsController < ApplicationController # GET /locations # GET /locations.json def index @locations = Location.all @json = Location.all.to_gmaps4rails end respond_to do |format| format.html # index.html.erb
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/.
2007 Oct 05
1
Custom helpers for list of options?
...ny of those models are just list of names, like country, state, city, profession ... I read about the country_select helper. Is better to have all those tables or use custom helpers? what the rails way? Thanks. For example : http://pastie.caboo.se/104092 # = Schema # country_id integer # city_id integer # state_id integer # profession_id integer # category_id integer # ...... class User < ActiveRecord::Base belongs_to :country, :city, :state belongs_to :profession, :category, :subcategory end =========== VS # = Schema # country :string # city :...