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.....
精彩评论