开发者

rails add new row in table

开发者 https://www.devze.com 2023-02-02 14:11 出处:网络
I have read in some tutorials about adding a column to an existing table. A question came across my mind, is it possible to add an additional row in the existing table

I have read in some tutorials about adding a column to an existing table. A question came across my mind, is it possible to add an additional row in the existing table

example,

I have a table of car, with attributes of :type and :colour and I have a method

def mymethod_todoinsertnewrowsincartable

insert car { :type => "BMW", :colour => "blue" }

开发者_运维百科end

How can I do this in above method? thank you


You can do it by following:-

Car.create(:type=>'BMW',:colour=>"blue")

Where Car is model name.

Thanks.....

0

精彩评论

暂无评论...
验证码 换一张
取 消