first application on Ruby on Rails
im begginer in RoR. help me please. i use windows xp, ruby 1.9.2, sqlite 3.7.5 it r my steps for creating new.
- install ruby
- gem install rails
- rails new C:\tm\test
- sqlite3.dll, sqlite3.exe
- gem install sqlite3-ruby
in database.yml:
development: adapter: sqlite3 dbfile: db/test.db
- C:\tm\test>sqlite3 -init db.sql test.db
- rails generate model Article
- rails generate controller Article
- in test\app\controllers\article_controller.rb: class ArticleController < ApplicationController scaffold :article end
- rails server in Firefox http://localhost:3000/article
and have trouble on page: ArgumentError No database file specified. Missing argument: database but i must seeinterface for work with table
in cmd after i see: ArgumentError (No database file specified. Missing argument: database):
in cmd after: 开发者_C百科rails generate scaffold Article Article
i spend this: Missing type for attribute 'Article'. Example: 'Article:string' where string is the type. help me please
It's now database
in YML, not dbfile
anymore. Try with the following yml in database.yml
:
development:
adapter: sqlite3
database: db/test.db
Here is a the guide to configure the database on rubyonrails.org.
The first answer is the correct one. If you are scraping your code and need a test start off doing something like this.
#!/usr/bin/env ruby
# Hyra Power
# 11/24/15
require 'active_record'
# ActiveRecord::Base.logger = Logger.new(STDERR)
# ActiveRecord::Base.colorize_logging = false
ActiveRecord::Base.establish_connection(
:adapter => "sqlite3",
:database => ":memory:"
)
ActiveRecord::Schema.define do
create_table :pages do |table|
table.column :url, :string, :null => false
table.column :title, :string
table.column :content_type, :string
table.column :last_modified, :datetime
table.column :error, :string
end
create_table :links do |table|
table.column :from_page_id, :integer, :null => false
table.column :to_page_id, :integer, :null => false
table.column :count, :integer
end
end
class Page < ActiveRecord::Base
has_many :links
end
class Link < ActiveRecord::Base
belongs_to :page
end
Test this script and then move on from there. Hope this helps anyone new.
i used: rake db: migrate. and i see this:
rake aborted! No database file specified. Missing argument: database
精彩评论