rails on ruby exmaples depot
1.install ruby
download from http://www.ruby-lang.org/en/news/2009/12/07/ruby-1-9-1-p376-is-released/
2.install rails
ruby gem install rails --include-dependencies
3.install mysql
download from http://sourceforge.net
ruby gem install mysql
1-3 can be down by download InstantRails from http://rubyforge.org/frs/?group_id=904 <InstantRails2.0.2>
4. create depot application:
ruby> rails --database=mysql depot
mysqladmin -u root create depot_development
ruby> rake db:migrate
ruby> ruby script/generate scaffold product title:string description:text image_url:string
ruby> ruby script/server webrick
IE: http://localhost:3000/product like below:
Listing products
TitleDescriptionImage url
NO1product
no1 product input by myself
Show
Edit
Destroy
New product
5.then can do modify the depot application........
Notice:
1-3 mybe failed, it result is Rails2.3.4 hte lastest version.
InstantRails 2.0.2 is more better for most pepole
相关文档:
1、文件的打开与关闭
``r'' Read-only, starts at beginning of file (default mode).
``r+'' Read-write, starts at beginning of file.
``w'' Write-only, truncates existing file to zero length or creates a new file for writing. ......
有些同学提问:我写数据到文件中会把老的数据替换掉。
怎么在源文件的基础上添加内容,而不是重写
【ruby code】
def txt_write(value,memo)
File.open("c:\\my_text.txt", 'a') do |f|
......
While looking for information on the subject, I looked into the ONLamp article Extending Ruby with C by Garrett Rooney, the Extending Ruby chapter in the Pickaxe, README.EXT (located at /usr/share/doc/ruby1.8-dev/README.EXT.gz on my Ubuntu system) and got some help from Kjetil.
The resulting file c ......
订单处置,首先要有一个订单的详细列表(包括数量,价钱啥的)和一个对于个人的一些信息的一个表。因而我们创造两个模型,line_item(列表项),order(列表),其后编者如次
/db/migrate xxx_create_order xxx_line_item
Ruby代码
一.class CreateOrders < ActiveRecord::Migration
二.def self.up
3. create_tabl ......
require 'win32ole'
excel = WIN32OLE::new('excel.Application')
workbook = excel.Workbooks.Open('E:\RubyApp\bmk.xls')
worksheet = workbook.Worksheets(1) #get hold of the first worksheet
worksheet.Select #bring it to the front -need sometimes to run macros, not for working with a worksheet from ru ......