similar to: Problem with options_for_select

Displaying 20 results from an estimated 100 matches similar to: "Problem with options_for_select"

2006 Mar 30
3
Rails 1.1, Markaby, options_from_collection
Last night, I upgraded one of my rails apps to 1.1. This app uses Markaby exclusively for its'' views, and once I checked out the latest revisiong of Markaby (r33), everything was working fine except for one thing: select_tag(''province_id'', options_from_collection_for_select(@provinces, "id", "name")) Now returns this (as you see it is spitting
2011 Feb 17
1
Select distinict on not chainable with order method
Hi. I would like to do code refactoring: @beers = [] Beer.all.each do |beer| unless @beers.find{|c| c.brand_id == beer.brand_id} @beers << beer end break if @beers.size > 29 end So I achieved this by writing scope (on PostgreSQL): scope :with_unique_brand, select("DISTINCT ON (beers.brand_id) beers.*") Using this scope alone is working
2008 Jul 22
2
ActiveRecord Associations issue
Hello all and thank you for reading this message. I am new to RoR, and ruby too, but i am quite excited about it. I am developing a RoR project and with active record associations in the following manner # Tables (all tables have only one record) CREATE TABLE `webcars_development`.`cars` ( `id` int(11) NOT NULL auto_increment, `model_id` int(11) NOT NULL default ''0'',
2010 Sep 17
1
option_groups_from_collection_for_select
Hi, in my development environment (Ruby 1.87, Rails 2.3.8) the following code works fine: <%= select "applicant", "member_1", option_groups_from_collection_for_select(@topics, :members, :topic, :id, :name, @applicant.member_1), {:include_blank => true} %> Producing: <optgroup label="Clinical Neuroscience"> <option value="1">Prof
2012 Mar 28
1
collection_select
_form.html.haml = f.label :Select_Brand, "Select_Brand<em>*</em>".html_safe = collection_select(:brand_name, :brand_id, Brand.all, :id, :name, :prompt => "Select a Brand" ) show.html.haml file %table %tr %td Brand_Name : %td = @message.brand_id After writing this code I am not able to see the brand name. Its not giving any error but
2006 Jun 30
0
Interpolation in association conditions broken; broken backwards-compatibility?
I believe it used to be possible to interpolate values into associations'' conditions with single quotes, but it isn''t anymore. has_many :widgets, :conditions => ''brand_id = #{brand_id}'' Anyone else remember that? It seems to have been snuffed out in changeset 3897 with the removal of interpolate_sql(@conditions) Was the change (and the fact that it
2007 May 30
2
newb trying to figure out ActiveRecord relationships
3 tables. item, brand, commercial item -------- id name brand_id name brand --------- id name commercial ---------- id item_id The idea is that a commercial will have one item. each item will have brand. and a brand may have zero to many items. I can''t figure out how to make the relationships for my models. Eventually, i''d like to be able to show a brand name from a
2006 Jul 19
5
weird result for a custom attr reader!
Hi all, I am having a weird problem reading a value from my model. basicaly, I have these two models: class Category < ActiveRecord::Base acts_as_tree :order => "name" belongs_to :item_type has_many :specific_category_names end and class SpecificCategoryName < ActiveRecord::Base set_table_name "Specific_category_names" has_many :products belongs_to
2006 Aug 09
1
Migrating a Field to External Model
I have a model Product with an attribute ''brand''. Currently it is a simple attribute, however, I am migrating it to a separate model Brand so that I can have other attributes with each brand. I created the the model and created and ran the migration to create the new table. So far so good. Then I created a separate migration to transfer the data. The up method
2006 Jul 15
1
Relationship problem, newbie problem, need help!!
Hey all I seem to be having some problems with my relationship between a few tables... If i then run the following query in mysql, i get the data i want. How do i do this in rails relationships and models? select * from shop_addresses left join shops on shops.id = shop_addresses.shop_id left join styles on styles.id = shops.style_id where shop_uri = ''127.0.0.1'' Cheers!!
2006 Feb 15
3
Like Query Across Multiple Tables
Firstly, I''m still learning Ruby and rails, so there could be a very simple solution to this. I want to search across multiple tables with a "like" query eg: (SQL is probably the easiest way to describe it): select products.* from products inner join brands on products.brand_id = brands.id where products.name like ''%canon%'' or brands.name like
2006 Sep 28
15
Inserting rows into linking table
Hi, I have two objects: Contacts Lists I want to be able to add multiple contacts to multiple lists. I''ve created a linking table and a form that allows me to select the contacts using checkboxes, but I''m having some problems with the controller and model. I receive the following error message when I submit the form: Mysql::Error: Cannot add or update a child row: a
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
2009 Jun 02
9
XML::LibXML::Reader
is there anybody who knows how we can get child values using libxml (Reader class) def xml_import_to_brands require''xml'' reader = XML::Reader.file(''c:/brands.xml'') . . .
2005 Oct 26
1
Re: collection_select question about selected_value
Paul Welty wrote: > collection_select(:client, :company_id, @companies, :id, :name, { > :selected_value => 2 , :prompt => "Please select a company..." }) > > Returns a functioning SELECT element, but it won¹t select the second item. > (BTW, using the selected_value as a string doesn¹t work either) > > Am I doing something wrong, or is this impossible? >
2009 Jul 23
11
Problem with named_scope
Here are my scopes: default_scope :order => ''posted_on DESC'', :conditions => { :status => ''visible'' } named_scope :positive, :conditions => { :rating => ''positive'', :status => ''visible'' } named_scope :neutral, :conditions => { :rating => ''neutral'', :status =>
2006 Jul 04
1
options_for_select - default nil value
I have a field in a view, like so: <%= select_tag(''quoted_condition'', options_for_select([''NEW'',''RETAIL'',''OEM'',''REFURB''], ''NEW'')) %> This sets the ''selected'' value to ''NEW'' - however, I would like to have a nil value here, so I can
2006 Jun 26
0
options_for_select-how to store cookie selected value ques.
#Controller cookies[:state] = state if state != nil and state.to_i != -1 conditions << ''stateid = ?'' cond_args << state cookies[:state] = state end if !cookies[:state].blank? @default_state = cookies[:state] else @default_state = "" end # view - html
2006 Mar 08
1
question about options_for_select array
Hi! If i have something like this used to create select tag: options = [["Dollar", "$"], ["Kroner", "DKK"]] and later read value from the database and get "DKK", what is the easiest way to get "Kroner" value? -- Posted via http://www.ruby-forum.com/.
2006 Jan 14
2
I think options_for_select is backwards
With a hash such as: stuff = {''1''=>''desc 1'', ''2''=>''desc 2'', ''3''=>''desc 3''} options_for_select(stuff) will output: <option id="desc 1">1</option> <option id="desc 2">2</option> <option id="desc 3">3</option>