Displaying 20 results from an estimated 1000 matches similar to: "option_groups_from_collection_for_select"
2008 Apr 10
3
option_groups_from_collection_for_select with a ActiveRecord::Base single object
Rails documentation gives examples of using
option_groups_from_collection_for_select with two tables/objects.
How could it be done with one?
Example that almost works:
I have a form to enter address from both the United States and Canada.
It has the following:
====new.html.erb====
<%= select_tag(
:state,
option_groups_from_collection_for_select(
State.countries,
:country,
2008 Nov 18
0
Scoping option_groups_from_collection_for_select
How can I scope the options returned by
option_groups_from_collection_for_select?
Method calls look like this: option_groups_from_collection_for_select
(collection, group_method, group_label_method, option_key_method,
option_value_method, selected_key = nil)
But say I want to limit the results returned by the option_key and
option_value methods to some particular scope?
For instance, using the
2010 Jun 18
1
[PATCH] option_groups_from_collection_for_select should produce an HTML-safe string
Can somebody please review my ticket:
https://rails.lighthouseapp.com/projects/8994/tickets/4879
It''s a trivial bugfix ("option_groups_from_collection_for_select
should produce an HTML-safe string") before RC, I think.
Cheers,
Wincent
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group.
To post to this group,
2009 Apr 03
0
Alpha sorting on both options and groups for option_groups_from_collection_for_select
# How would you best perform a secondary sort on :buildings below?
= ''Building Name''
= select_tag ''building_id'', |
option_groups_from_collection_for_select(Site.all(:order => :full_name), |
:buildings, :full_name, :id, :full_name, nil) |
--
Thanks,
Tyler Arrigoni
President
OneInterface.net Network Engineering, Inc.
7475 North Palm, Suite 105, Fresno,
2006 Jul 14
6
Get a collection through ActiveRecord for using with option_groups_from_collection_for_select
Hello,
I am having some difficulties with ActiveRecord.
What I want to do is to get a collection of SubjectGroups for using
with option_groups_from_collection_for_select
My Code:
========================================
class Subject < ActiveRecord::Base
has_and_belongs_to_many :users
belongs_to :subject_group
end
class SubjectGroup < ActiveRecord::Base
has_many :subjects
end
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
2010 Jun 17
1
Problem with options_for_select
Hi,
I have a problem with the form select. In the value field I have the
generated html...
<%= f.select :brand_id,
options_for_select([[''Brands'', 0]] +
@search_brands.map { |b| [b.name, b.id]}),
{:id => ''cbxBrand'', :tabindex => (@tabindex += 1)} %>
This is the html:
<select name="search[brand_id]"
2008 Jul 07
0
HAML and nestings
I have this partial:
1 - bairros = bairros_select
2 - selected_id ||= nil
3 - if bairros.any?
4 - cid = nil
5 = select_tag :imovel, :bairro_id do
6 - for b in bairros
7 - sel = b.id == selected_id ? {:selected => true} : {}
8 - if cid != b.cidade_id
9 %optgroup= b.cidade.cidade
10 - cid = b.cidade_id
11 %option{sel, :value =>
2006 Oct 18
1
optgroup and Javascript Issues
Is there a way to walk a select box that has multiple enabled and a few
optgroup mixed in with other groups?
The following seems to work without the optgroup tags in a multiselect
list box. I have tired going threw the children of the optgroup but i
was unable to pull a valid .value or .selected.
Any Ideas? Thanks.
var objGroups =
2014 Apr 24
0
How to make optgroup with rails version 3
I am trying to set up a drop down list with a optgroup with active users. i
know the following code is wrong, but would there be any way of doing this
how i have it? right now if you take the raw section and just have
data.collect {|a| [ a.name, a.id ] } instead, it works great for just
showing the names of the users, but i want to add that optgorup. How would
i go about doing that?
=
2006 Jun 16
0
Getting error on a group select
Hi,
I''m very new with Ruby and Rails. I have read Agile Web Development
with Rails and was trying to create a grouped selection list by
following his example on page 359.
My helper looks like this:
module LoginHelper
AssocOption = Struct.new(:code_name, :display_name)
class AssocType
attr_reader :type_name, :options
def initialize(name)
@type_name = name
2006 Jun 16
0
Getting an error on options_groups_from_collection_for_select
Hi,
I''m very new with Ruby and Rails. I have read Agile Web Development
with Rails and was trying to create a grouped selection list by
following his example on page 359.
My helper looks like this:
module LoginHelper
AssocOption = Struct.new(:code_name, :display_name)
class AssocType
attr_reader :type_name, :options
def initialize(name)
@type_name = name
2009 Mar 26
0
Rails 2.3.2 nested forms, option_groups etc
Working in 2.3.2 and working from the examples in Github for nested
forms, this works fine for simple text fields, or simple selects but
option_groups_from_collection_for_select is a bit more complicated.
The js code he''s used generates a template to be used for each nested
form, but it does it in the simple example by using a f.select helper.
This will generate the correct html for the
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
2012 May 13
1
is assert_select_rjs deprecated in Rails 3.1 ?
I have seen it in 3.0.9 doc (
http://apidock.com/rails/v3.0.9/ActionDispatch/Assertions/SelectorAssertions/assert_select_rjs
)
but it''s not mentioned in the latest guide (
http://guides.rubyonrails.org/testing.html#integration-testing-examples)
if deprecated how can I check the view from an Ajax call
( assert_match + gsub could work ? ... )
am I missing any doc ?
xhr :get, :change_area,
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?
>
2011 Mar 09
1
ActiveRecord serialize method not returning YAML array in test environment.
Hello,
I''ve got a problem with deserialization of AR "serialize" method
(http://apidock.com/rails/ActiveRecord/Base/serialize/class) in my
tests.
It just gives me pure String instead of my data Array.
Example:
User > AR::Base
serialize :roles, Array
end
Console:
u = User.new
u.roles = ["admin", "support"]
u.save
# => true
User.first.roles
# =>
2016 Feb 03
1
[PATCH] generator: simplify generated code for always-available features
Just refer to the dummy function directly, instead of using #define's.
---
generator/daemon.ml | 12 ++++--------
1 file changed, 4 insertions(+), 8 deletions(-)
diff --git a/generator/daemon.ml b/generator/daemon.ml
index 7ffea7b..d1689e1 100644
--- a/generator/daemon.ml
+++ b/generator/daemon.ml
@@ -732,19 +732,15 @@ and generate_daemon_optgroups_c () =
pr " return 1;\n";
2006 Mar 16
4
calling an actionview method from inside a model
Hi,
I would like my model instance to produce it''s own list of options for
a form select. This is from a product model that has_many variations
def alts_for_select(current_id)
the_map = variations.map{|v| [v.name, v.id]}
options_for_select(the_map, current_id)
end
the model cannot see the options_for_select method
I tried to use
2006 Jan 23
3
problem with a selfmade helper method
Hi all,
i tried to set up the helper method "grouped_programs_selector" in
application_helpers.rb. Since i dont have a deep understanding of Ruby
itself, I pretty much copied the Grouped Selection List (Chapter 17, pp.
259, 260) example from Dave & David''s Book.
The optiongroups are properly created by my method, but there are no options
inside. Maybe you can debug this