Displaying 20 results from an estimated 5000 matches similar to: "Select not providing default option"
2005 Dec 15
2
Select/Option selected value
I''m trying to get a select box to populate with the current option for editing
purposes. I can populate the box, but not with the currently selected value.
I''ve read in the api where it says to do this:
# Example with @post.person_id => 1:
# select("post", "person_id", Person.find_all.collect {|p| [ p.name,
p.id ] }, { :include_blank =>
2006 Apr 06
6
select method
The documentation states as an example:
select("post", "person_id", Person.find_all.collect {|p| [ p.name, p.id ] },
{ :include_blank => true }) could become:
<select name="post[person_id]">
<option></option>
<option value="1" selected="selected">David</option>
<option
2006 Jul 04
1
select(object, method, choices, options = {}, html_options = {})
Hi,
I''m using:
select(object, method, choices, options = {}, html_options = {})
I''ve read the API where there''s this example:
select("post", "person_id", Person.find_all.collect {|p| [ p.name,
p.id ] }, { :include_blank => true })
should give this code:
<select name="post[person_id]">
<option></option>
2006 May 15
0
collection_select and API docs questions
Hello,
I''m wondering where in the docs am I suppose to find a complete list of
options for the collection_select helper?
For instance the API docs have an example for the select helper as
below:
select("post", "person_id", Person.find_all.collect {|p| [ p.name,
p.id ] }, { :include_blank => true })
Where the heck do I find valid values for the options and
2006 Feb 21
4
Select error
This code:
<p>
<label for="resource_type">Type</label><br/>
<%= select(:resource, :type, %w{ Web Data }, { :include_blank => true
}) %>
</p>
Produces this error:
TypeError in Resources#new
Showing app/views/resources/_form.rhtml where line #6 raised:
wrong argument type String (expected Module)
Extracted source (around line
2006 Mar 06
2
form_tag error -- not found, 404 -- action DOES exist!
Hi -- I''ve got a very strange error.
I have an action called ''commit_input'' on a controller called
''SiteVisitController''. This definately exists, and is called from the
functional test for it, and passes fine.
My problem is with the form that is supposed to call this action.
The form tag is:
<%=
2006 Feb 27
0
Example code for select_from_db (a.k.a. combo box)
I''m not asking for help this time! :) :) In almost every Rails
project I create, I find that I want a select() popup menu that is
pre-populated by data from the database. Also, I want an "Other..."
option that presents a text_field_tag to input another (not
presented) option (basically a combo-box). In an attempt to be as
DRY as possible, I''ve come up with
2007 Jul 17
5
habtm confusion
Hello friends!
I am trying to make a database that will have a group of people set to
committees, and a person can be in multiple committees, and a committee
obviously has multiple people. The people are senators at my
university. These are my current models:
senator.rb:
--
class Senator < ActiveRecord::Base
validates_presence_of :first_name, :last_name, :floor
has_and_belongs_to_many
2006 Jan 01
7
Can''t get select helper to populate dropdown w/default value
Guys,
I searched this forum and found plenty of people having this problem,
but I didn''t see any definitive solution. Usings Rails 1.0.
When I edit an existing record, I can''t get the basic "select" helper to
display the current value contained in the field of the record. All of
my other (text) fields populate correctly with current field values.
There appears
2006 Jun 28
6
select_tag
in my controller
@cursos = Curso.find_all
in my view i''m trying to do a select_tag with the results @cursos, using
a helper
select_tag "name" options_for_select(@cursos) --------> not works
select_tag "name" @cursos --------> not works
how to do it, using the helper?
tks
--
Posted via http://www.ruby-forum.com/.
2006 Jun 25
3
select box''s
Hi,
I have this code for a select box,
<%= select("plugin", "plugcats", Plugcats.find_all.collect {|p| [
p.title, p.id ] }, { :include_blank => true }) %>
at the minute it extracts teh requried data, but submits the data as
params[''plugin''][''plugcats'']
how can I get it to submit it as
2006 May 18
4
Problems using ''select''
I use :filter action to display form and allow record filtering. It
contains form with
combo box, submit button and list of record matching value in combo.
filter.rb:
class Filter
attr_accessor :owner
def initialize(params)
@owner = '''';
if !params[:filter].nil? and params[:filter].has_key?(:owner)
@owner = params[:filter][:owner]
end
end
end
Controler:
@users =
2006 Aug 02
2
Self-Referential has_many :through
Hello all.
I am trying to create a self-referential has_many :through. I used the
following site as a guide
http://blog.hasmanythrough.com/articles/2006/04/21/self-referential-through
but it still doesn''t appear to be working. I have two models. Person and
Relationship. A person has many contacts (Which is another person)
through relationships
class Person < ActiveRecord::Base
2006 Mar 29
0
has_and_belongs_to_many and collections management
Sorry for the big post. I''m having a lot of confusion when trying to
implement a simple model relationship that uses all the good things of
ActiveRecord.
I need to store some dinamic entries about knowledge of certain people on
the database. A knowledge is measured with another table, with a range of
possible values for a knowledge. This is a reduced schema of my database:
create table
2011 Oct 05
3
Rails 3 Select_tag in javascript give missing ; error
When I write
var x = "<%= select_tag(:activity_group,
options_for_select(activity_grp),{:include_blank => ''Create New
Group'', :style => ''width: 100px''}) %>";
where <% activity_grp = @activity_group.map { |ag| [ag.name,
ag.id] } %>
However, I get error (missing ; before statement) in Firebug because
var x = "<select
2005 Dec 29
3
Post problem with select lists
hey,
i have this problem
how come i always get -1 for the select list??
rhtml
First, select a client.
<select id="client_id" name="client[id]" onChange="submit();" >
<%= options_for_select(@client_options, @client_id.to_i) %>
</select><%= @client_id %>
controller
if @request.post?
if @request.xml_http_request? #called by ajax,
2006 Aug 12
0
select in form_remote_for
I am trying to use a slect box in my form, but I am stuck with an error
I cannot understand...
here is what I wrote according to the documentation ...
<%= f.select ("property", "user_id", User.find_all.collect {|u| [
u.name u.id ] }, { :include_blank => true }) %>
user_id is a FK to a user (owner of the property)
Associations : User has_many properties,
2006 Jun 28
0
habtm and multiple-option select boxes
I''ve got a fairly basic has_and_belongs_to_many setup, with a Business
model and a Category model. In the admin functionality for the Business,
I''d like to have a multiple select box showing all of the Categories, with
included ones selected, etc.
I''m stumped as to how to do it, though - it seems like there should be an
easy way, but I''m missing it looking
2006 Jan 18
3
retrieving value from select
In my view, I have:
<%= select("division_filter", "division_id", Division.find_all.collect
{|p| [ p.division, p.id ] }, { :include_blank => true }) %>
How do I retrieve the division_id in my controller?
--
Posted via http://www.ruby-forum.com/.
2008 May 02
1
names of select elements inside a fields_for block not generated as expected
Hey All,
I''m trying to play along w/the ''complex forms 1'' railscast
(http://railscasts.com/episodes/73) and having trouble. The view is
projects/new. I''m trying to add some project_people to the form w/code
like so:
<% form_for(@project) do |f| %>
[project stuff here]
<% for pp in @project.project_person %>
<% fields_for