ActiveScaffoldãè¤æ°ã¢ãã«ãå¢ããã¦ãã§ããã ãå ±éãã¥ã¼ã®ç·¨éã§æ¸ã¾ããããã®ï¼
ActiveScaffoldãè¤æ°ã¢ãã«ãå¢ããã¦ãã§ããã ãå ±éãã¥ã¼ã®ç·¨éã§æ¸ã¾ããããã®ï¼
ä»åã¯Railsã®è©±ã
ããWebï¼DBã·ã¹ãã ã§æ±ããããã¼ã¿ãã¼ã¹å
ã®å
¨ãã¼ãã«ã«å¯¾ãã¦ãRailsï¼ActiveScaffoldã§ãã¼ãã«å
容æ¤ç´¢ã»é²è¦§ã»CSVåºåç»é¢ãã±ã±ã±ã£ã¨ãæ軽ã«ä½ãå¿
è¦ãã§ã¾ããã
åç´ã«ããã
- ãã¼ãã«ãï¼ã¤è¿½å
- ã¢ãã«ãï¼ã¤è¿½å
- ãã¥ã¼ãï¼ã¤è¿½å â¦
ãªã©ã¨ããã¨ãããã¦æ©è½ãå¤ãããªããã©ã½ã¼ã¹ãæ´¾çãã¦å¢ãç¶ãã¦ãã¾ãã
ææªæ´¾çã³ãã¼ã許ãã¨ãã¦ããã³ãã¼ããå¾ã§æãå
¥ããç®æãã§ããã ãå°ãªãåºæ¥ãã»ããå¹çãè¯ãã
ã¨ãããã¨ã§ãã¾ãæå§ãã«ãã³ã³ããã¼ã©ãå¢ãç¶ãã¦ãããã¥ã¼ã¯æ¥µåå
±éãã§æ¸ãæ¹æ³ãæ¤è¨ãã¾ãã
Railsã¯1.2.5ãç·¨éç°å¢ã¯Aptana Studio1.2.1ã§ãã
ActiveScaffoldã®ãã©ã°ã¤ã³ã¯å°å
¥æ¸ã¿ã®ç¶æ
ããéå§ã
db:migrationããã¢ãã«ä½æãä¸éãçµãã£ãç¶æ
ããã§ãã
Personã¢ãã«ï¼person_controller.rbï¼ã®ããã©ã«ãå 容
class PersonController < ApplicationController active_scaffold :person layout "layout" end
layoutè¡ã§ãPersonã¢ãã«ã«ã¯"layout"âlayout.rhtmlãã¡ã¤ã«ããã¥ã¼ã¨ãã¦åç
§ãããè¨å®ã«ãªã£ã¦ãã¾ãã
ããã©ã«ãã§ã¯ã©ã®ã³ã³ããã¼ã©ã§ãåãã®ããã§ãã
ãã¥ã¼ layout.rhtml ã®ããã©ã«ãå 容
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; utf8" /> <title>é²è¦§ãã¼ã¸</title> <%= javascript_include_tag :defaults %> <%= active_scaffold_includes %> </head> <body> <%= yield %> </body> </html>
ããã©ã«ãã®layout.rhtml ã®å
容ã¯ããã£ã¦ã·ã³ãã«ããããã表ç¾ãå¢ããã¦ã¿ã¾ãã
ç§ãæåã«æ°ã«å
¥ããªãã£ãã®ã¯titleã¿ã°ã"é²è¦§ãã¼ã¸"ã§æè¨åºå®ã§æ°ãå©ãã¦ãªãç¹ã
ããããã©ã®ã¢ãã«ã«å¯¾å¿ãããã¥ã¼ï¼é²è¦§ãã¼ã¸ï¼ã§ãã©ã®ã¢ã¯ã·ã§ã³ã®å¦ççµæã§è¡¨ç¤ºãããã®ãã追å ãã¦ã¿ã¾ãã
以ä¸ã®è¡ã«å¯¾ãã¦ã
<title>é²è¦§ãã¼ã¸</title>
controllerãªãã¸ã§ã¯ãã®æ å ±ãåãè¾¼ãã§è¡¨ç¤ºããã¾ãã
<title> <%= controller.controller_name %> é²è¦§ãã¼ã¸ <%= controller.action_name %></title>
ãã¥ã¼ã®ä¸ã§åç §ãã¦å©ç¨ã§ãããªãã¸ã§ã¯ãã¯ãã¾ã
- ã³ã³ããã¼ã©å´ã§ã¢ã¯ã·ã§ã³ãå®è¡ãããéã«ä½æãããã¤ã³ã¹ã¿ã³ã¹å¤æ°ï¼@personã«æ ¼ç´ãããããï¼
- å種ãã«ãã¼ã¡ã½ãã
ã主ãªãã®ã§ããããã以å¤ã«ãç°å¢æ å ±ã¨ãã¦ä»¥ä¸ãå©ç¨ã§ãã¾ãã
- prams
- flash
- session
- hedders
- response
- request
- logger
- controller
ä»åã¯ããã«flashãåããã¦ã以ä¸ã®å 容ã§layout.rhtmlãä¿åãã¾ããã
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; utf8" /> <title> <%= controller.controller_name %> é²è¦§ãã¼ã¸ <%= controller.action_name %></title> <%= javascript_include_tag :defaults %> <%= active_scaffold_includes %> </head> <body> <p style="color: green" id="flashbox"> <%= flash[:notice] %> </p> <p> <a href="/">ããããã¼ã¸ã«æ»ã</a> </p> <%= yield %> </body> </html>
ããã§ä¾ãã°ã/person/ ã«ã¢ã¯ã»ã¹ããã¨ãã¼ã¸ã®ã¿ã¤ãã«ã"person é²è¦§ãã¼ã¸ index"ã¨ãªãã¾ãã
ã¢ã¯ã·ã§ã³ãå
¥ããã®ã¯å¥½ã¿ã§ããããã