Displaying 20 results from an estimated 5000 matches similar to: "collection_select and API docs questions"
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 Jun 10
4
collection_select question
How do I specify which option should be initially selected when using
the collection_select command? I''ve tried:
collection_select(:selectionfilter, :producer_id, Producer.find(:all),
:id, :name, {:include_blank => true, :selected_value =>
@initial_selection})
However it doesn''t return the desired results (the option with the value
of @initial_selection selected).
2006 Apr 25
1
simple collection_select problem.
Hi,
I can do this :
collection_select "state", :id, TrainingState.find_all,:id,:name
but not this :
collection_select "state[]", :id, TrainingState.find_all,:id,:name
Anyone any idea why? Is there something about collection_select that
does not allow collections?
Thanks
Chris
--
Posted via http://www.ruby-forum.com/.
2006 May 15
2
collection_select and validation problems
I keep getting the error below when I use validations with
collection_select.
You have a nil object when you didn''t expect it!
You might have expected an instance of Array.
The error occured while evaluating nil.inject
Extracted source (around line #22):
19: <td>Vendor</td>
20: <td>
21: <!-- vendors -->
22: <%=
2006 Apr 03
2
undefined method `scaffold'' for #<LocationsController:0xb7a9e858>
Would anybody know why I get this error from this bit of code:
class LocationsController < ApplicationController
def index
scaffold :locations
end
end
This is the way that is demonstrated in the screencast for creating a
quick scaffold. I have done this before. However, I come back to
working with Ruby after about a month on something else and now it
gives this error.
Any
2010 Feb 22
3
Rails 2.3.5/Ruby1.8.7 Collection_Select Labels with ampersands "&"
I am having an annoying problem displaying the labels of a select box
correctly where there is an ampersand contained within the label
string.
On a form being rendered with the form_for helper the
collection_select reads data from a Mysql 5.075 database the text
stored in the database is "Surabaya & Surrounding Areas" when rendered
and displayed in firefox 3.6 or safari is is
2007 Dec 22
3
collection_select validation problem
I''m trying to assign a parent foreign key value using
collection_select from my child "new" form. The problem I''m having is
if I do not make a selection, I get the following error instead of the
Rails validates_presence_of error:
You have a nil object when you didn''t expect it!
You might have expected an instance of Array.
The error occurred while evaluating
2006 Jan 25
1
Collection_select ?
In case where a collection_select is selecting a required value for an
object (a not null field), is it possible to set a generic default value
for the select box? I have tried :prompt => true and :include_blank =>
true but neither changes the value for required fields. It does for
non-required fields though.
Thanks.
Nathan Mealey
Operations Director
Northeast Region
Pilgrim IT,
2006 Mar 23
1
Select not providing default option
Hello all.
I am running Rails 1.0 and am having trouble with the select box. In the
API it says.
"Create a select tag and a series of contained option tags for the
provided object and method. The option currently held by the object will
be selected, provided that the object is available. See
options_for_select for the required format of the choices parameter."
and then goes on to
2006 Feb 28
2
Need help with a Power Find()
I was hoping someone would be able to help me with creating a method.
I have two tables. What I am trying to do is create a list of all the id''s
from table2 that aren''t currently referenced by Table1''s address_id column.
That way, when I create a new customer I can have a drop down list in the
view of all the addresses that are not currently being used.
##### Database
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 Jul 16
6
using collection_select
hello,
supposing i have a User class that contains a Wibble
class User < ActiveRecord::Base
has_one :wibble
end
in my view i have
<%= collection_select :user, :wibble, Wibble.find(:all), :id, :name %>
when i post, i get an error like
"Wibble expected, got String"
how/where am I supposed to convert this posted wibble_id into a
Wibble, or am I using collection_select
2006 May 18
6
Newbie:problem when using validates*
Hi,
I have performed the cookbook tutorial. Before tailoring the views and
controllers, when I put in the model recipe.rb:
validates_uniqueness_of :title
validates_length_of :title, :within => 1...20
And I tried to introduce some new recipe without the above conditions I
got the message:
---------------------------------------------------
New recipe
1 error prohibited this category from
2006 Sep 27
0
NET::LDAP Help Anyone? Maybe session Help? Bring my server to it's knees Help?
Does anybody know what the correct way to cache results from
Net::LDAP bind_as? I''ve been struggling for about a day now and I
know it''s something really easy. But when ever I do something like
this -
def self.login(username, password)
begin
ldap = Net::LDAP.new
ldap.host = "192.168.1.16"
ldap.port = 389
result = ldap.bind_as(
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
2005 Jul 06
1
collection_select not selecting the selected item
Hi !
I have Event belongs_to Category. The generated source is:
<p><label for="event_category">Category</label><br/>
<select id="event_category" name="event[category]">
<option value="8">Introduction</option>
<option value="7">Programming</option>
</select></p>
Notice no
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 Jul 20
0
Getting joined collections on a form
Greetings, I''m looking for suggestions on how to simplify getting customer
addresses on a form:
I''m jumping between controller and view several times; alternating between
rhtml and rjs, in order to display customers and their addresses on an
invoicing form. It''s very messy.
I have a one to many relationship between Customer and Addresses, each
customer has one or more