Displaying 20 results from an estimated 1000 matches similar to: "collection_select"
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'')
.
.
.
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).
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'',
2011 Aug 31
0
ERB and binding in template
How to get current binding in a partial (to use helpers and local
variables in erb script)?
When I invoke result whithout binding,
= ERB.new("script").result.html_safe
all work (without vars are needed), but when I write
= ERB.new("script").result(binding).html_safe
(in HAML HTML partial), THE PARTIAL''S REST OF OUTPUT IS CLEAR.
What is the problem?
--
Posted
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
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 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 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
2012 Apr 09
0
Autocomplete text-field version of dynamic select menu?
I have a form for submission of brand, model, and style. Style
belongs_to model, and model belongs_to brand. The form is actually a
style submission form, but allows users to create new brands or models
as well, should they not exist.
What I want is for the autocomplete for ''model'' to populate when an
object for ''brand'' is selected in the first text field..
2010 Aug 03
7
rails 2.3.8 and html_safe
Hi,
Can somebody update me on the state of html_safe strings in rails 2.3.8?
I know rails 2.3.6 and 2.3.7 broke a lot of code because strings were
being escaped when they shouldn''t have been and I thought this was all
fixed in 2.3.8.
I''m upgrading an app from 2.3.5 to 2.3.8 and there are many spots where
previous code was output correctly and now it expects html_safe method
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
2010 Jun 17
3
Can i use a hash on a collection_select? If don't, alternatives.
In my current application, i have food categories: mexican, home made,
japanese, ect
As these categories only have ID and name, no other attributes, i dont
want to create a table on the DB.
My first idea was to create a constant named FOOD_CATEGORIES, that is
has like:
FOOD_CATEGORIES = { 1=>''mexican'',
2=>''japanese'',
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
=>
2012 Aug 16
6
undefined method `with_indifferent_access' for "":String
Hi
I''m having a issue with one object when try to update the attributes in
this object previously saved in the database
I have one object comp and one object reg they have this relationship
comp
has_many regs
reg
belongs_to comp
when run use the method valid? like this
current_contribuyente.comps.build(params[:comp]).valid?
it returns: IndexError (string not matched)
And when
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 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
2009 Jan 08
4
Problem with disable_with
Hi Group,
I have a registration.html.erb page with the following JavaScript at
the top which I use to validate form fields:
<script type="text/javascript">
<!--
function validate(){
if ((document.myForm.email_projectname.value=="")||
(document.myForm.email_projecttype_id.selectedIndex<1)||
(document.myForm.email_region_id.selectedIndex<1))
{
alert
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,
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