similar to: collection_select with array as source

Displaying 20 results from an estimated 1000 matches similar to: "collection_select with array as source"

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'',
2006 Mar 12
2
Default option in collection_select
I need a way to set a default in a collection_select. Any way? -- Posted via http://www.ruby-forum.com/.
2005 Dec 30
9
SELECT MAX
How does one do a SELECT MAX query in rails? I''ve searched and searched and tried lots of things with no luck. I want to implement "SELECT MAX(column_name) from table_name and have it return the maximum value from column_name. I just need to get that one value, not the whole object... Thanks for any ideas... Shelby _______________________________________________ Rails mailing
2006 Jun 15
3
how to give a form a name
Using a <%= form_tag ... %>, how do I give a form a name, so that I can reference it with javascript? I sure can''t figure this out from the docs... Thanks, Shelby PS - what I am trying to do is just have the focus in the first form field when the form is loaded. There has to be an easy way to do this, but I can''t figure it out... -------------- next part --------------
2005 Dec 17
2
Storing an object in the db
I''ve asked this before, but never got a working response. I''d like to store an object inside a binary field in my db. So I''d have a class like this class MyAwesomeClass def do_something_awesome ... end end then class MyRecord < ActiveRecord::Base end the table my_record would have a binary field, my_object, that would store an object of
2006 Jun 13
7
model validation across multiple views
I have a rather complex object with a number of attributes. For a variety of reasons, I would like one view to create the object with only a couple of fields completed, then a second and third view to finish all the fields. I would like the model to validate_presence_of all these fields, since eventually I need them all there, and I would like each page to validate its portion of the fields that
2010 Mar 24
2
Mock "Consent_6335" received unexpected message :marked_for_destruction? with (no args)
I have a mock object (Person) that is associated with another object (my_object) through a belongs_to association. When I check whether my_object is valid (my_object.should be_valid), I am getting an error like the following: Mock "Person_6338" received unexpected message :marked_for_destruction? with (no args) Checking the list of methods on the mock,
2006 Jul 09
2
serialized DateTime objects returning as Time objects
I have a database field called dates in which I am trying to serialize an array of DateTime objects. When I unserialize them, they are coming back in as Time objects. I know this, because I am getting errors that say "comparison between Time and DateTime failed. Why is this happening? Is there a way to prevent it?? Thanks Shelby -------------- next part -------------- An HTML attachment
2006 Aug 02
3
faster? database search or rewriting objects
I''m having an argument with my son :) I have a table with about 1500 objects called entries. I need to do something with about 100 of them (schedule manually) I say I should just mark them with a boolean when I have scheduled them. (manual == true) My son says I should pull them out of the entries table and copy them to new objects (lets call them "manual" objects, and store
2007 Dec 08
3
Uploading photos using facebook & attachment_fu
Hi All, I''m trying to use a form to upload a photo that I will save using attachment_fu. I''m very new to Facebookr so I apologize if this is covered somewhere, but I''m kind of stumped. Here''s what I''m doing now: <% facebook_form_for(:my_object, :url => { :action => ''upload_photo'', :id => params[:id] }, :html => {
2005 Dec 27
3
myObject.send(column.name) from Agile Development book
I''m studying the Agile Development with Rails book. In the chapter that first sets up the depot application (page 68), there is this bit of code from a view: <% for product in @products %> <tr> <% for column in Product.content_columns %> <td><%=h product.send(column.name) %></td> <% end %> etc... I am trying to absorb both Ruby and
2005 Aug 07
3
tracking online users
Let''s say I have an application and I want to create an admin program that will show me who is currently online using the application. I don''t know the best way to do this. Assuming I am storing my sessions in the default PStore, I don''t suppose there is any method that lists all the active sessions, is there? The only way I can think of to do this is to setup a
2006 May 09
1
Reusing a model to form and link_to.
Hy guys, Inside my app I have a form which contains user information. Sometimes a have a form with a text_field as above: <%= form_remote_tag(:html => { :action => url_for(:controller => "my_controller", :action => "my_action") }) %> <%= text_field(''my_object'', ''my_parameter'', :maxlength =>
2005 Dec 31
4
saving a collection
Reading the Agile book, I can''t find a single command to save a collection. The save command seems to operate on only individual objects. Lets say I have a collection that I have received from a find_all command. I want to go through and change some attributes in various objects in the collection. Then I want to resave the whole collection back to the database. I don''t think
2007 Jun 23
4
inverse examples? (should fail)
The new "pending" example feature reminds me of a feature I''ve been bouncing around in my head, to aid in refactoring. Often, when I''m changing existing behaviour, I know that certain aspects of the old behaviour should change. Imagine changing the "it" method to perhaps "not" or "old" or "removed"... The behaviour would be to
2006 Apr 27
3
collection_select to display 2 fields
I''m trying to get a collection_select generated Drop-down box to display two fields from a table (first name & last name); however, I am having trouble concatenating the symbols. It appears as though any code I put in the 5th argument for collection_select is processed prior to executing the collection_select method. The code executes successfully with 1 symbol in the 5th
2005 Dec 26
2
confused about ruby fast C bindings
I am confused about ruby fast C bindings. Does the command: gem install mysql install these? Is this page: http://www.tmtm.org/en/mysql/ruby/ the home page for these bindings? If so, it gives no instructions about installing them with using gem. Wondering if this is all the same??? Thanks for any help... Shelby _______________________________________________ Rails mailing list
2006 May 24
0
Problems validating form with collection_select
I have the following models: class Comandancia < ActiveRecord::Base has_many :elementos end class Elemento < ActiveRecord::Base belongs_to :comandancia validates_presence_of :nombre, :apellido_paterno, :apellido_materno, :comandancia end In the view for New Elemento I''m using <%= start_form_tag :action => ''create'' %> <%= render :partial =>
2006 Apr 21
0
collection_select has_and_belongs_to_many update_attributes
I know there have been threads on this before but I was thinking shouldn''t multiple collection_select automatically update habtm relations when you update_attributes? In order to get multiple collection_select to work I use: collection_select(:user, :group_ids, Group.find(:all), :id, :name,{},{:multiple=>'''',:name=>''group[id][]''}) In fact if I
2006 Nov 26
0
concatenate fields in collection_select
Hi, I am filling a collection_select with a list of models references based on a column named "model_ref". <%= collection_select(:assets, :model_id, @models, :id, :model_ref,:prompt => ''- Select a model -'') %></p> I have two issues : 1) I would like to concatenate another column next to the model reference inside the option value with the description