I have an associative array: @moldout = ["out_mmcost" => "#{@out_mmcost}", "out_packcost" => "#{@out_packcost}", "out_othercost" => "#{@out_othercost}"] I have a table MOLDOUTS with these attributes: id, out_mmcost, out_packcost, out_othercost I need to insert these values in @moldout array into the table MOLDOUTS. I tried: @moldou_obj = Moldout.new(params[@moldout]) @moldou_obj.save doesn''t work tho.. Does anybody know solution..? Thanks a lot..
Steven Critchfield wrote:> On Wed, 2005-09-14 at 17:02 +0100, Steven Mohapi-Banks wrote: > >>You may also need to call "set_table_name" because I''m not sure if >>ActiveRecord is case-sensitive or not (like below) > > > ActiveRecord downcases the name if not specifically specified. So the > question isn''t if ActiveRecord is case sensitive, but rather if the > database under it is sensitive enough to complain. > >It''s not just database-specific - in MySQL''s case (har har), the case sensitivity depends, eminently sensibly, on the case sensitivity of the underlying filesystem. Whether the following breaks or not by default varies depending on the platform: mysql> create table My_Test_Table(Name varchar(255)); mysql> insert into my_test_table set name=''foo''; I don''t know how other databases handle this - I''ve conditioned myself to always lower-case everything now :-) For more fun, laughter and frivolity, check out http://dev.mysql.com/doc/mysql/en/name-case-sensitivity.html... -- Alex
Try: @moldou_obj = Moldout.new(@moldout) @moldou_obj.save You may also need to call "set_table_name" because I''m not sure if ActiveRecord is case-sensitive or not (like below) class Moldout < ActiveRecord::Base set_table_name "MOLDOUTS" end Rgds, Steve On 14 Sep 2005, at 16:44, milos kelemen wrote:> I have an associative array: > @moldout = ["out_mmcost" => "#{@out_mmcost}", > "out_packcost" => "#{@out_packcost}", > "out_othercost" => "#{@out_othercost}"] > > I have a table MOLDOUTS with these attributes: id, out_mmcost, > out_packcost, out_othercost > I need to insert these values in @moldout array into the table > MOLDOUTS. > > I tried: > @moldou_obj = Moldout.new(params[@moldout]) > @moldou_obj.save > > doesn''t work tho.. > > Does anybody know solution..? > > Thanks a lot.. > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
On Wed, 2005-09-14 at 17:44 +0200, milos kelemen wrote:> I have an associative array: > @moldout = ["out_mmcost" => "#{@out_mmcost}", > "out_packcost" => "#{@out_packcost}", > "out_othercost" => "#{@out_othercost}"]Just to save you some typing, but you don''t need all those quotes, pounds, and curly braces. @moldout = ["out_mmcost => @out_mmcost, "out_pack_cost" => @out_packcost, "out_othercost" => @out_othercost ] See a little cleaner and a lot less shift some key typing.> I have a table MOLDOUTS with these attributes: id, out_mmcost, > out_packcost, out_othercost > I need to insert these values in @moldout array into the table MOLDOUTS. > > I tried: > @moldou_obj = Moldout.new(params[@moldout]) > @moldou_obj.saveAt least in this example, your variables aren''t in params, and may be the problem. In this example you should use @moldou_obj = Moldout.new(@moldout) You also may be getting caught up in some validation error. If you run that test via the console app you should be able to inspect the error returned better to figure out any other problems. -- Steven Critchfield <critch-wQLwMjUOumVBDgjK7y7TUQ@public.gmane.org>
On Wed, 2005-09-14 at 17:02 +0100, Steven Mohapi-Banks wrote:> You may also need to call "set_table_name" because I''m not sure if > ActiveRecord is case-sensitive or not (like below)ActiveRecord downcases the name if not specifically specified. So the question isn''t if ActiveRecord is case sensitive, but rather if the database under it is sensitive enough to complain. -- Steven Critchfield <critch-wQLwMjUOumVBDgjK7y7TUQ@public.gmane.org>
Steven Critchfield wrote:> On Wed, 2005-09-14 at 17:44 +0200, milos kelemen wrote: > >>I have an associative array: >>@moldout = ["out_mmcost" => "#{@out_mmcost}", >> "out_packcost" => "#{@out_packcost}", >> "out_othercost" => "#{@out_othercost}"] > > > Just to save you some typing, but you don''t need all those quotes, > pounds, and curly braces. > > @moldout = ["out_mmcost => @out_mmcost, > "out_pack_cost" => @out_packcost, > "out_othercost" => @out_othercost ] > > See a little cleaner and a lot less shift some key typing.>>> thank you> > >>I have a table MOLDOUTS with these attributes: id, out_mmcost, >>out_packcost, out_othercost >>I need to insert these values in @moldout array into the table MOLDOUTS. >> >>I tried: >>@moldou_obj = Moldout.new(params[@moldout]) >>@moldou_obj.save > > > At least in this example, your variables aren''t in params, and may be > the problem. In this example you should use > > @moldou_obj = Moldout.new(@moldout) >>>> I''ll try that too, it throws me an error: >>>undefined method `stringify_keys!'' for [{"out_eoq"=>12, "out_setup"=>12, "out_chgover"=>1}]:Array> You also may be getting caught up in some validation error. If you run > that test via the console app you should be able to inspect the error > returned better to figure out any other problems.>>> don''t really know what you ment by this... i''m newbie in ROR
On Sep 14, 2005, at 12:21 PM, milos kelemen wrote:> Steven Critchfield wrote: >> On Wed, 2005-09-14 at 17:44 +0200, milos kelemen wrote: >>> I have an associative array: >>> @moldout = ["out_mmcost" => "#{@out_mmcost}", >>> "out_packcost" => "#{@out_packcost}", >>> "out_othercost" => "#{@out_othercost}"] >> Just to save you some typing, but you don''t need all those quotes, >> pounds, and curly braces. >> @moldout = ["out_mmcost => @out_mmcost, "out_pack_cost" => >> @out_packcost, >> "out_othercost" => @out_othercost ] >> See a little cleaner and a lot less shift some key typing. > > >>> thank you > >>> I have a table MOLDOUTS with these attributes: id, out_mmcost, >>> out_packcost, out_othercost >>> I need to insert these values in @moldout array into the table >>> MOLDOUTS. >>> >>> I tried: >>> @moldou_obj = Moldout.new(params[@moldout]) >>> @moldou_obj.save >> At least in this example, your variables aren''t in params, and may be >> the problem. In this example you should use >> @moldou_obj = Moldout.new(@moldout) > >>> I''ll try that too, it throws me an error: > >>>undefined method `stringify_keys!'' for [{"out_eoq"=>12, > "out_setup"=>12, "out_chgover"=>1}]:Array@moldout is an one element Array with a Hash as its first element. Try making it a plain Hash: @moldout = {''out_mmcost'' => @out_mmcost, ... } Moldout.new(@moldout) -- Scott Barron Lunchbox Software http://lunchboxsoftware.com http://lunchroom.lunchboxsoftware.com
>It''s not just database-specific - in MySQL''s case (har har), the case >sensitivity depends, eminently sensibly, on the case sensitivity of the >underlying filesystem. Whether the following breaks or not by default >varies depending on the platform: > >mysql> create table My_Test_Table(Name varchar(255)); >mysql> insert into my_test_table set name=''foo''; > >I don''t know how other databases handle this - I''ve conditioned myself >to always lower-case everything now :-) > >For more fun, laughter and frivolity, check out >http://dev.mysql.com/doc/mysql/en/name-case-sensitivity.html... > > >PostgreSQL - lowercase on non-quoted identifiers. i.e. MyTable, MYTABLE and "mytable" are the same, but "MyTable" is not. Oracle - Just like Postgres, except that non-quoted identifiers default to upper case.
Scott Barron wrote:> > On Sep 14, 2005, at 12:21 PM, milos kelemen wrote: > >> Steven Critchfield wrote: >> >>> On Wed, 2005-09-14 at 17:44 +0200, milos kelemen wrote: >>> >>>> I have an associative array: >>>> @moldout = ["out_mmcost" => "#{@out_mmcost}", >>>> "out_packcost" => "#{@out_packcost}", >>>> "out_othercost" => "#{@out_othercost}"] >>> >>> Just to save you some typing, but you don''t need all those quotes, >>> pounds, and curly braces. >>> @moldout = ["out_mmcost => @out_mmcost, "out_pack_cost" => >>> @out_packcost, >>> "out_othercost" => @out_othercost ] >>> See a little cleaner and a lot less shift some key typing. >> >> >> >>> thank you >> >>>> I have a table MOLDOUTS with these attributes: id, out_mmcost, >>>> out_packcost, out_othercost >>>> I need to insert these values in @moldout array into the table >>>> MOLDOUTS. >>>> >>>> I tried: >>>> @moldou_obj = Moldout.new(params[@moldout]) >>>> @moldou_obj.save >>> >>> At least in this example, your variables aren''t in params, and may be >>> the problem. In this example you should use >>> @moldou_obj = Moldout.new(@moldout) >> >> >>> I''ll try that too, it throws me an error: >> >>>undefined method `stringify_keys!'' for [{"out_eoq"=>12, >> "out_setup"=>12, "out_chgover"=>1}]:Array > > > @moldout is an one element Array with a Hash as its first element. Try > making it a plain Hash: > > @moldout = {''out_mmcost'' => @out_mmcost, ... } > > Moldout.new(@moldout) > >NOW IT WORKS... THANKS A LOT SCOTT... thanks to everyone..