开发者

rails add new row in 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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜