softwarebookéçºç°å¢ã®å¾©å
ããããMacBookã«å
ã®ç°å¢ãæ»ã£ããç¾å¨ã¯productionã¢ã¼ãã§テスト運用中ã
ä»åãソースコードを色付けして記述する(シンタックス・ハイライト)ã¨ããæ¹æ³ããããã¨ãåãã¦ç¥ã£ã¦ã使ã£ã¦ã¿ããã¡ãã£ã¨ãè²ãããããæ°ããã...ãスーパーpre記法のカスタマイズãåèã«è¨å®ãå¤ãã¦ã¿ããã©ãRadRailsã®ããã©ã«ãã«ã©ã¼ã¨åãã«ããã®ã¯é£ãã...ã
ãã¦ã³ãã¼ã
ä»åãRailsã®éçºç°å¢ã®ããã«ãã¦ã³ãã¼ãããã®ã¯ä»¥ä¸4ã¤ã®ãã¡ã¤ã«ã
Locomotive_2.0.8.dmg | Railsç°å¢ã®ããã®ã½ããã¦ã§ã¢ããã±ã¼ã¸ |
---|---|
radrails-0.7.2-macosx-carbon.tar | Xcodeã®ãããªGUIã®éçºç°å¢ |
pleiades_1.2.0.p5.zip | RadRailsã®æ¥æ¬èªåã®ãã |
subversion-client-1.3.1.dmg | ãã¡ã¤ã«ã®å±¥æ´ç®¡çã®ãã |
MySQLã®ä»£ããã«Sqlite3*1ãå©ç¨ãããã¨ã«ããã®ã§ã以åããæ軽ã«å°å ¥ã§ãããSqlite3ã§ã¯ããã¼ã¿ãã¼ã¹ã®è¨å®ãå¿ è¦ãªãã®ã§éçºä¸ã¯ãã£ã¡ã®æ¹ããããããããªãã以ä¸ã®ãããªé åãããã
-
- config/database.ymlã®è¨å®ãã¨ã£ã¦ãç°¡åãã¦ã¼ã¶ã¼ããã¹ã¯ã¼ãã®è¨å®ãå¿ è¦ãªãã
- ãã¼ã¿ãã¼ã¹ãæ°è¦è¿½å ããªãã¦ãããããªããã¤ã°ã¬ã·ã§ã³ãå®è¡ã§ããã
- ãã¼ã¿ã¯dbãã©ã«ãã«ãã¡ã¤ã«ã¨ãã¦ä¿åããããã¨ã«ãªããã½ã¼ã¹ã³ã¼ãã¨ä¸ç·ã«é å¸ã§ããã®ã§ãããã«ãµã³ãã«ã¨ãã¦åä½ç¢ºèªã§ããã
Locomotiveã®è¨å®
Locomotive2ãã©ã«ããã¢ããªã±ã¼ã·ã§ã³ãã©ã«ãã«ãã©ãã°ï¼ããããããã ãã
RadRailsã®è¨å®
æ¥æ¬èªå
解åããradrailsãã©ã«ããã¢ããªã±ã¼ã·ã§ã³ãã©ã«ãã«ãã©ãã°ï¼ããããããããã¾ãã¯æ¥æ¬èªåãæé ã«ã¤ãã¦ã¯ãRadRailsを日本語化する。ãã§ããã¦ã³ãã¼ããããã¡ã¤ã«ã¯ãpleiades_1.2.0.p5ã¨ãã¼ã¸ã§ã³ãä¸ãã£ã¦ããããåãæé ã§æ¥æ¬èªåã§ããã
ç°å¢è¨å®
MacBookã«Locomotiveãã¤ã³ã¹ãã¼ã«ããç°å¢ã§ãRadRailsãå©ç¨ããè¨å®ãã¡ãã¥ã¼ããç°å¢è¨å®ãéãã¦ã以ä¸ã®ããã«è¨å®ããããã®ä»ã®è¨å®ã¯ã好ã¿ã§ãRadRailsãæ¥æ¬èªåãã¦ããã¨ãç°å¢è¨å®ã§è¨å®å 容ã®ããããã®è¦å½ã¯ä»ãããã«ãªã£ãã
- Ruby >> Ri/rdoc >>
RDoc ãã¹ | /Applications/Locomotive2/Bundles/standardRailsSept2006.locobundle/i386/bin/rdoc |
---|---|
Ri ãã¹ | /Applications/Locomotive2/Bundles/standardRailsSept2006.locobundle/i386/bin/ri |
- Ruby >> ã¤ã³ã¹ãã¼ã«æ¸ã¿ã®ã¤ã³ã¿ã¼ããªã¿ã¼ >>
ã¤ã³ã¿ã¼ããªã¿ã¼å | 1.8.4 in Locomotive |
---|---|
ãã±ã¼ã·ã§ã³ | /Applications/Locomotive2/Bundles/standardRailsSept2006.locobundle/i386/bin/ruby |
- Rails >> æ§æ >>
Rails ãã¹ | /Applications/Locomotive2/Bundles/standardRailsSept2006.locobundle/i386/bin/rails |
---|---|
Rake ãã¹ | /Applications/Locomotive2/Bundles/standardRailsSept2006.locobundle/i386/bin/rake |
Mongrel ãã¹ | /Applications/Locomotive2/Bundles/standardRailsSept2006.locobundle/i386/bin/mongrel_rails |
- ä¸è¬ã>> ã¯ã¼ã¯ã¹ãã¼ã¹ >>
èªåçã«æ´æ° | ãã§ãã¯ãã |
---|---|
ããã¹ãã»ãã¡ã¤ã«ã»ã¨ã³ã³ã¼ã | ãã®ä» UTF-8 |
æ°è¦ããã¹ãã»ãã¡ã¤ã«ã®è¡åºåãæå | ãã®ä» Unix |
subversionã®è¨å®
ã¤ã³ã¹ãã¼ã©ã¼ã®æé ã«å¾ã£ã¦ã¤ã³ã¹ãã¼ã«ãã¦ãããè¨å®ã¨ç°¡åãªä½¿ãæ¹ã¯ãSubversionでファイルのバージョン管理をしてみる。ãã§ã
Sqlite3ã®Railsããã¸ã§ã¯ããä½æ
ãã¼ã ã«railsappãã©ã«ããä½æãã¦ãã¿ã¼ããã«ãã以ä¸ãå®è¡ã
cd ~/railsapp rails softwarebook --database=sqlite3
ããã¨ãconfig/database.ymlã以ä¸ã®ããã«è¨å®ããã¦ããããã®è¨å®ã¯ããã®ã¾ã¾å©ç¨ã§ãããMySQLã®æããç°¡åã ã
# SQLite version 3.x # gem install sqlite3-ruby development: adapter: sqlite3 database: db/development.sqlite3 # Warning: The database defined as 'test' will be erased and # re-generated from your development database when you run 'rake'. # Do not set this db to the same as development or production. test: adapter: sqlite3 database: db/test.sqlite3 production: adapter: sqlite3 database: db/production.sqlite3
ãã©ã°ã¤ã³ã®ã¤ã³ã¹ãã¼ã«
Specialãã©ã°ã¤ã³
RadRailsã®ãRailsãã©ã°ã¤ã³ãã¿ãã«åå¨ããªãã®ã§ãã¿ã¼ããã«ã§ä»¥ä¸ã®ã³ãã³ããå®è¡ããã
cd ~/railsapp/softwarebook script/plugin install http://wota.jp/svn/rails/plugins/branches/stable/special
EnginesãLoginEngineãUserEngineãã©ã°ã¤ã³
RadRailsã®ãRailsãã©ã°ã¤ã³ãã¿ãããé¸æãã¦ãç°¡åã«ã¤ã³ã¹ãã¼ã«ã§ããã
ã¢ãã«ã®ä½æ
RadRailsã®ãã¸ã§ãã¬ã¼ã¿ã¼ãã¿ãã§...
- å·¦ã®ãªã¹ãããmodelãé¸æãã¦ãå³é ç®ã«softwareãå ¥åãã¦ãå®è¡ãã¿ã³ã
- å·¦ã®ãªã¹ãããmodelãé¸æãã¦ãå³é ç®ã«keywordãå ¥åãã¦ãå®è¡ãã¿ã³ã
ãã¼ã¿ãã¼ã¹ã®æ§ç¯
ãã¤ã°ã¬ã¼ã·ã§ã³ã®è¨å®
ä¸è¨ã¢ãã«ãä½æããæã«èªåçã«çæããããã¡ã¤ã«ãã以ä¸ã®ããã«è¨å®ããã
- db/migrate/001_create_softwares.rb
class CreateSoftwares < ActiveRecord::Migration def self.up create_table :softwares do |t| t.column :title, :string t.column :description, :text t.column :url, :string t.column :created_on, :datetime t.column :updated_on, :datetime t.column :keyword_id, :integer t.column :user_id, :integer end end def self.down drop_table :softwares end end
- db/migrate/002_create_keywords.rb
class CreateKeywords < ActiveRecord::Migration def self.up create_table :keywords do |t| t.column :name, :string end end def self.down drop_table :keywords end end
ãã¤ã°ã¬ã¼ã·ã§ã³ã®å®è¡
ä¸è¨ã§è¨å®ããsoftwareãkeywordãä½æ | RadRailsã®ãRake ã¿ã¹ã¯ãã¿ãã§ãdb:migrateãé¸æãã¦ãå®è¡ãã¿ã³ã |
---|---|
LoginEngineãUserEngineã®ãã©ã°ã¤ã³ç¨ã®ãã¼ãã«ãä½æ | RadRailsã®ãRake ã¿ã¹ã¯ãã¿ãã§ãdb:migrate:enginesãé¸æãã¦ãå®è¡ãã¿ã³ã |
bootstrapã®å®è¡
UserEngineã®rolesãpermissionsãusersãã¼ãã«ã®åæè¨å® | RadRailsã®ãRake ã¿ã¹ã¯ãã¿ãã§ãbootstrapãé¸æãã¦ãå®è¡ãã¿ã³ã |
---|
jascaffoldã®å®è¡
RadRailsã®ãã¸ã§ãã¬ã¼ã¿ã¼ãã¿ãã§...
- å·¦ã®ãªã¹ãã«jascaffoldã¨å ¥åãã¦ãå³é ç®ã«softwareãå ¥åãã¦ãå®è¡ãã¿ã³ã
- å·¦ã®ãªã¹ãã«jascaffoldã¨å ¥åãã¦ãå³é ç®ã«keywordãå ¥åãã¦ãå®è¡ãã¿ã³ã
configãã©ã«ãã®è¨å®
- config/environment.rb
- Ruby GetTextãLoginEngineãUserEngineã«é¢ããè¨å®
$KCODE = 'u' # 'u'=UTF-8, 's'=SJIS, 'e'=EUC-JP require 'jcode' # Stringã¯ã©ã¹ã®ã¡ã½ãããªã©ãã$KCODEã«æå®ããæåã³ã¼ãã§é©åã«åä½ããããã«ç½®ãæããã ...ï¼éä¸çç¥ï¼... # Include your application configuration below # Ruby-GetText-Packageã使ãå®£è¨ require 'gettext/rails' # Ruby GetTextã«msgmergeã®ãã¹ãæãã¦ããã ENV['MSGMERGE_PATH'] = '/Applications/Locomotive2/Bundles/standardRailsSept2006.locobundle/i386/bin/msgmerge' module LoginEngine config :salt, "ror-salt" # æå·åã®ãã¼ãä½ã§ããã # Source address for user emails config :email_from, 'éä¿¡å ã¡ã¼ã«ã¢ãã¬ã¹' # å±ããã¡ã¼ã«ã®fromæ¬ã«è¡¨ç¤ºãããã # Destination email for system errors config :admin_email, 'ã·ã¹ãã 管çè ã®ã¡ã¼ã«ã¢ãã¬ã¹' # Sent in emails to users config :app_name, 'Softwarebook' # ã¡ã¼ã«ã®ã¿ã¤ãã«ã«æ¿å ¥ããããã¼ã¯ã¼ãã«ãªãã end module UserEngine config :admin_login, "zarigani" config :admin_email, '[email protected]' # 'zariganiã¦ã¼ã¶ã¼ã®ã¡ã¼ã«ã¢ãã¬ã¹' config :admin_password, 'zarigani' end Engines.start :login, :user # å¿ ã:loginãæåã«æ¸ã UserEngine.check_system_roles
- config/environments/development.rbãproduction.rb
- LoginEngineãã¡ã¼ã«ãéä¿¡ããæã®è¨å®
...ï¼éä¸çç¥ï¼... ActionMailer::Base.server_settings = { :address => "smtp.mac.com", :port => 25, :domain => "smtp.mac.com", :user_name => ".Macã®ã¦ã¼ã¶ã¼å", # ã¡ã¼ã«ã¢ãã¬ã¹ã®@ã®æåã¾ã§ :password => ".Macã®ãã°ã¤ã³ãã¹ã¯ã¼ã", :authentication => :login }
appãã©ã«ãã®è¨å®
- app/controllers/application.rb
- Ruby GetTextãLoginEngineãUserEngineã«é¢ããè¨å®
# Filters added to this controller will be run for all controllers in the application. # Likewise, all the methods added will be available for all controllers. require 'login_engine' class ApplicationController < ActionController::Base init_gettext "softwarebook" include LoginEngine include UserEngine helper :user model :user #before_filter :login_required before_filter :authorize_action end
- app/helpers/application_helper.rb
- LoginEngineãUserEngineã«é¢ããè¨å®
# Methods added to this helper will be available to all templates in the application. module ApplicationHelper include LoginEngine include UserEngine end
- app/views/layouts/user.rhtml
- LoginEngineãUserEngineã«é¢ããè¨å®
<html> <head> <title>Softwares: <%= controller.action_name %></title> <%= engine_stylesheet "user_engine" %> <%= engine_javascript "user_engine" %> </head> <body> <% for name in [:notice, :warning, :message] %> <%= "<p style=?"color: green?">#{flash[name]}</p>" if flash[name] %> <% end %> <%= yield %> </body> </html>
*1:Locomotive_2.0.8ã«å«ã¾ãã¦ããã