Displaying 20 results from an estimated 100000 matches similar to: "Editing a serialized hash with a Rails form"
2007 Jul 06
0
Removing One Element From a Serialized Form
Hi all,
I''m trying to serialize a form with the exception of one specific
element.
Serializing the form in a hash (without pulling out specific elements)
works:
<li>
<%= link_to_remote ''(Save)'', {:url => post_path(@post), :with => "$
(''post_form'').serialize(true)" }, :method => :put %>
</li>
The generated code
2008 Jul 26
0
fixtures, how to set a serialized Hash object
I defined in my model :
...
serialize :unavailables
..
which is set like this (Hash : "year" => 2-dimensional Array)
{"2008" => Array.new(13).map!{ Array.new(32, 1)} }
In my fixture I need to initiliaze this field with the following
hash :
{"2008" => Array.new(4).map!{ Array.new(32, 1)} + Array.new(1).map!
{ [1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2008 Oct 10
2
Add hash to serialized column
Hey guys,
I''m trying to merge a hash with another using the .merge! function.
class User < ActiveRecord::Base
serialize :preferences
end
This is what I end up with in the console:
>> u = User.find(1)
>> u.preferences.merge!{:test => 1}
SyntaxError: compile error
(irb):32: syntax error, unexpected tASSOC, expecting ''}''
u.preferences.merge!{:test
2009 Jan 21
3
Nested serialization with to_json and to_xml with array and hash element
Title: Nested serialization with to_json and to_xml with array and
hash element
class Person < ActiveRecord::Base
has_one :address
has_one :job
def office()
return "Executive_Suite"
end
end
class Address < ActiveRecord::Base
belongs_to :person
end
class Job < ActiveRecord::Base
belongs_to :person
has_one :paygrade
def Title
return "Engineer"
end
end
2008 Jul 08
0
Bug with serialized columns in console ?
Hi,
I recently added 2 serialized columns in my class Server :
class Server < ActiveRecord::Base
serialize :visa, Hash
serialize :appli, Array
...
No problem in my controller and my application and everything works as
expected : Excel exports following the "visa" Hash or "appli" Array
are ok.
But since I added the visa Hash, I can''t load the record with
2007 Jun 14
3
serialize with sortable_element (rails)
creating multiple lists with sortable_element and would like to
serialize them and save back to the db.
i have the sorting between multiple lists working properly. can anyone
point me in the right direction for serializing and saving?
thanks
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby on Rails:
2007 Oct 19
0
Rails 2.0 serialize
ActiveRecord in Rails 1.2.x has a method: serialize(attr_name,
class_name = Object). I was wondering, given the new JSON
serialization in 2.0, if it will be possible to request JSON instead
of YAML when serializing data to a database column? Same goes for XML.
It seems logical to modify the method to: serialize(column_name,
options = {}).
Then you could do something like:
class User <
Form.serialize(this) returning empty string in onSubmit, Ajax.Update context, works in Firebug watch
2007 Apr 10
0
Form.serialize(this) returning empty string in onSubmit, Ajax.Update context, works in Firebug watch
This page is ripped from a real application, but its been simplified
for debugging, turning off authentication and hiding Secret Sauce®.
So if you try
Form.serialize(''bio_form'')
in Firebug you''ll get a url-encoded string back.
The parameters to the Ajax.Updater() call a wrapper around
Form.serialize which should present an alert with the url-encoded
string. It
2007 Apr 23
1
Using Array or Hash with Form Select and Elsewhere
I''m working on a small project in order to learn Rails. I have a model
with a status field, which I want to be ''open'' or ''closed'' (I may add
some other options later). I am storing them in the database all
lowercase (later options might be abbreviated in the DB). To display
things nicely, I want them to appear as ''Open'' or
2008 Apr 22
1
Problem with Prototype 1.6.0.2, Opera 9 and Form.serialize()
Hello,
following code fragment given:
~~~
function jsPostAppend(script, form_id)
{
if(form_id)
//parameters=''&'' + $(form_id).serialize() // first flavour
parameters=''&'' + Form.serialize($(form_id)) // second flavour
[...]
~~~
This works perfect for FF2, IE7 and Safari3 (in both flavours).
With Opera 9.x, I get the following javascript errors:
2006 Dec 09
1
validates_uniqueness_of serialize
ActiveRecord bug ?
validates_uniqueness_of
doesn''t work with
serialize
I''m trying to serialize, unserialize an Array-type property of a Object
instance, and validate that the Array or serialized version is unique
within the the scope of another property using :scope
does anyone know a work around ?
Anthony Green
--
Posted via http://www.ruby-forum.com/.
2009 Mar 19
1
form_tag params hash doesn't contain form data
Hi,
I have a check box in a non - model based form and when I submit
the form with ''Un Checked'' check box the params hash doesn''t contain
the check box. Whenever I submit the form with the check box
''Checked'', I see the same coming through params hash in my controller.
Since I dynamically generate the form element (Here, check box), if I
2008 Oct 21
6
detecting width overflow in serialized column with mysql
So I''ve got an ActiveRecord model pointing to a MySQL db, with an
auto-serialized column ("serialize :columnName").
Thing is, MySQL, depending on how it''s configured (like, by default),
has a bad habit of just truncating your data if it''s too wide for the
column, with no error raised. Yeah, I can probably reconfigure MySQL
and/or my AR connection to it. But
2006 Mar 22
4
Serialized form... problems with accents
Hi,
I''m working on a french website and I use the Form.serialize method to
send the info through AJAX. The thing is that the accentuated letters
(é,ê,à, etc.) don''t get replaced by their HTML entities and they get
corrupted when retrieving the data. How could I fix that?
thanks a lot,
Blaise Bernie
2006 Aug 10
3
How to serialize a symbol coming from a Form
Hello, I would like to use serialized symbols as values for select in
forms.
eg.
class Vehicle < ActiveRecord::Base
@@statuses = {:wait => ''No yet'', :ok => ''Run run run''}
validates_inclusion_of status, :in => @@statutes.keys
Serialize status, Symbol
def self.statuses
@@statuses
end
end
Then, I can use Vehicle.statuses.invert to
2007 Apr 14
2
Form.serialize: correctness and speed
The following link does a comparison of some popular libraries and
their ability to correctly serialise a form:
<URL: http://www.malsup.com/jquery/form/comp/ >
Any comments?
--
Rob
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group.
To post to this group, send email to
2006 Apr 03
6
problems with Rails 1.1 observe_field :with serialized
I''d like to use observe_field to watch a field, and then when it changes
send the entire form to the server. I had been using
<%= observe_field ''entity_name_''+@account.id.to_s, :frequency => 0.5,
:update => ''auto_complete_''+@account.id.to_s, :url =>
{ :controller => ''committees'', :action=>
2008 Jan 11
1
Remote form for, Form.serialize and parameter arrays
Whenever I use regular form for and have an attribute list containing
an array all goes fine and it results in parameters like:
{"some_attributes"=>[{"title"=>"first_title", "text" => "text1"},
{"title"=>"second_title", "text"=>"text2"}]}
However whenever I submit the same form with
2006 Nov 01
0
Re: YAML.load(some_string) doesn't return hash?
Oleg Kh wrote:
> A small problem here. As per documentation on
> http://corelib.rubyonrails.org/classes/YAML.html YAML.load(string)
> should just return a hash. However on my windows machine it returns
> something like this:
>
> #<YAML::Syck::DomainType:0x36d5038
> @domain="yaml.org,2002",
> @type_id="map:HashWithIndifferentAccess",
>
2009 Mar 25
6
Hash with key and value from ActiveRecord?
Heya,
I think I have thinking barrier. I just want a simple hash out of an
ActiveRecord.
@attributes = Attribute.find_all_by_character_id(@character).hash {
|u| [u.name, u.value] }
and I would like to access it like
@attributes[:health]
but it doesn''t work. Anyone can help me out with that?
--
Posted via http://www.ruby-forum.com/.