named_scope
- with_scope ã£ã¦ã®ãå¨ã£ããã
- ãã㦠scope ã«ååãä»ãããã
- ãããåæã§ãã
- éåã®ç©ã®ããã«
- ã¡ã½ãããã§ã¤ã³ã§
- SQLã¬ãã«ã§åæãã¦ããããANDç¹ãã®ã¿ã§å¾ããã
- ORDER ã¨ã LIMIT ã¯å åã¡ã2.3ã§å¤ããæ¹åãã
scope_do
- 諸æ©ããã®ãã©ã°ã¤ã³(GitHUb)
- ä½ãé¢é£ã¯ãªããã ãã©è¯ã使ã named_scope ãå¹¾ã¤ãéãã¦ãããã®
- GitHub - moro/scope_do: named_scope utilities(include deleted ChainedScope..)
Description scope_do is a tiny utilities to define useful named_scope. scope_do provides . named_acl : enable User - Group - Target style access control list. . chained_scope : enable defined named_scope method chain. . has_children : define scope to load child records
- named_acl
- 便å©ã§ã
- ã¿ã¼ã²ããã¯èªåã§æå®ãã
- via ã¨ãæ¡ä»¶ã¨ããé©å®æå®ããã¨ããåæã«æ¢ãã¦ãããã
- ååå¤ãããã
- chained_scope
- æ¡ä»¶ã空ã ã£ããä½ãããªã scope ãä½ãããã«ããã
- ãããããªæ¤ç´¢æ¡ä»¶ã並åãã¦ããã¨ããæå®ããã¦ãªãã£ãã scope ãçããªãã¦ããããã ãããã§ãä¸ã ãããªæ¡ä»¶å¼æ¸ãã®å¤§å¤ã ã
- has_children
- åè¦ç´ ãã©ãã ã以ä¸ãããã¨ãã® scope ãä½ã
- ã¹ããã¯
- scope_do ã®ã¹ããã¯ããããã工夫ãã¦ã
- DBé¢ä¿æ±ããªãããã«ã¨ã
- ãã¡ã¯ããªã¼ã¬ã¼ã«
- ãã©ã°ã¤ã³ã®ãã¹ãã®æ¸ãæ¹
- fixturesæ¸ãã®å¤§å¤ã ã
- scope_do ã®ã¹ããã¯ããããã工夫ãã¦ã
- SQLã¯ã¨ãªã®æ¸ãæ¹
- ãã¨ã§åæãããããã®æ³å®ãã¦ãããã工夫ããã
- ã¯ã¨ãªæé©åãæ³å®ãããã確ãããã
Rack
Rubyã§æ¸ããã WSGI (Webãµã¼ãã®ã²ã¼ãã¦ã§ã¤ã¤ã³ã¿ã¼ãã§ã¼ã¹)
Webã¢ããªã±ã¼ã·ã§ã³ãã¬ã¼ã ã¯ã¼ã¯ã¨ãWebãµã¼ãã®éã§ã¤ã³ã¿ã¼ãã§ã¼ã¹ã仲ä»ãããWAF ããã®ã¤ã³ã¿ã¼ãã§ã¼ã¹å¯¾å¿ã«ãã¦ããã°ãä¸ã® Webãµã¼ããããããåãæ¿ããã¨ãã¯ã¤ã³ã¿ã¼ãã§ã¼ã¹ãé¢åè¦ã¦ããããRails(2.2ãã)ãMerb ã¨ãã« Rack 対å¿ã«ãªã£ã¦ãã
RackUp -> .ru
Rack 㯠Webã¢ããªã±ã¼ã·ã§ã³(ãªã¯ã¨ã¹ããåãåã£ã¦ãã¬ã¹ãã³ã¹æååãè¿ãå½æ°)ã®å¤§æ ã®æ çµã¿ãããã¦ã»ãã·ã§ã³ã¨ããã¨ã©ã¼ãã³ãã©ã¼ã¨ããããããªé¨åããµã¼ãã©ãã¯ã«ç©ãã§ããããã«çµã¿è¾¼ãã
Webãµã¼ãã¯ã½ã±ããããªãã¹ã³ãã¦è´ããäºã«å¿ãã¦ããããå¦çãå¼ã³åºããå¼ã³åºãæ¹ã¨ãè¿ãæ¹ã¨ãã®ã¤ã³ã¿ã¼ãã§ã¼ã¹ã Rack ã«ãªãããµã¼ããã¢ããªå ±ã«è¡åãè¯ãã£ããªããã¤ã³ã¿ã¼ãã§ã¼ã¹ã¯ä»æ§ã¨ãã¦åå¨ãã¦ãã ãã§è¯ãã£ãããã ãããããRuby ãªã®ã§ãã®è¾ºããããæ··æ²ã¨ãã¦ãã®ã§ãã§ãããããããããææãªã®ã§ãå®éã®ä»²ä»å¦çã¾ã§è¡ãããã°ã©ã ã¨ã㦠Rack ãåå¨ãã¦ãããããã¦æµè¡ãå§ãã¦ããã
Rack ã®å種 Webãµã¼ãã®ã¢ããã¿ã¼ãèªãã¨ãããããã® Webãµã¼ãããã°ã©ã ã®ãµã¼ãåä½ã§ã®ä½¿ãæ¹ãåãã£ã¦ãããããã
Rackèªä½ã®ä»æ§ææ¸ã¯ Rackæ¬ä½ã® SPEC ã«ãã!
i18n_generator
ã¡ãã£ã¨å ¥é
lib\ruby\gems\1.8\gems\activesupport-2.2.2\lib\active_support\vendor\i18n-0.0.1 以ä¸ã2.3以é㧠0.1.1 ã§ã¡ãã£ã¨è¯ããªã£ã¦ããAPIã¯å¤ãã£ã¦ãªãã仲è¯ããªã£ã¦ãã
ãè¦ãããtranslteãt ã¨ããã¡ã½ããã翻訳ãlocaizeãl ã¯é貨ã¨ãæéã¨ãã®èª¿æ´ã
ãã¨ããã¯ã¨ã³ããæå㯠simple.rb ã®ã¿ãé·ããªãããããããè¦ãã°åããã
è¨èªã¨ãã±ã¼ã«ã®å¥æå®ãå¯è½ã¯å¯è½ã
ä½ãããã¸ã§ã¯ãä½ã£ã¦
ã³ã³ã½ã¼ã«ã§ãI18n.t ã§ç¿»è¨³ãI18n.locale ã«å¾ã£ã¦ãyaml ããèªãã 翻訳ãªã½ã¼ã¹ã®ä¸è¦§ããã£ã¦ãããI18n.backend è¦ã«è¡ã£ã¦ãã®ã確ããããbaskendåãæ¿ããã¨ããä½ãç´ãã°ãããããããã¯ã¨ã³ãã®ç¿»è¨³ãªã½ã¼ã¹ã DB ã«ããããGetText ã«åºæ¥ããå¬ãããªããã ãããããªãããªãã
Rails ã®å®è£ ããã¡ãã»ã¼ã¸ã¨ãç´æ¸ãã ã£ãã®ããããå¼ã³åºãããã«å¤ãã¦ããã翻訳ãªã½ã¼ã¹ã¯ locale/ï¼ãªãã¨ãï¼.yml
railsã®è¨å®
config/environment.rb
config.i18n.default_locale = 'ja'
ãã®ä¸ã§ããã©ã¦ã¶ããã®ãªã¯ã¨ã¹ãã«ãããã£ã¦ãé½åº¦ I18n.locale ã調æ´ããã°ã¦ã¼ã¶æ¯ã«åãæ¿ããã¨ãå¯è½ããªãããµã³ãã«ã ããã©ã°ã¤ã³ã ããã£ãã
GitHub ã® amatsuda ããã®æã«ããããæ å ±ã¨ããã£ããã
i18n_generators
ã¸ã§ã
- amatsuda-i18n-generators
i18n_scaffold ã¨ã使ããããã«ãªã£ã¦ã¦ãããã§ããããã㨠script/generate i18n ja
ã¢ã¯ãã£ããµãã¼ãã¨ãã¢ã¯ãã£ãã¬ã³ã¼ãã¨ããµãã·ã¹ãã å¥ã«ç¿»è¨³ãªã½ã¼ã¹ã config/locales ã«ä½ã£ã¦ãããããããããªããæ¹ã§ç¿»è¨³ãããããã¹ã¯ã¬ã¼ãã³ãããããã¦ããã¢ãã«ã¨ãã¢ããªã±ã¼ã·ã§ã³å´ã®ç¿»è¨³ã¯ã°ã¼ã°ã«ç¿»è¨³ã¨ãã
è¯ã翻訳ãã©ããã«ã¹ãã¢ããã®ã大å¤ã ãã
ã°ã¼ã°ã«ç¿»è¨³ã®çµæ以å¤ã®æååãæ¢ã«è¨å®ããã¦ããå ´åã¯ã°ã¼ã°ã«ç¿»è¨³ã§ã®ä¸æ¸ãã¯ããªããæã§èª¿æ´ããåã¯æ®ãã空æååã""ãã触ããªãã
ã°ã¼ã°ã«ç¿»è¨³ãã¼ã¯ã¨ãä»ãã¦ãã¨ãã¯ã©ããªãã ããã#~Gãã
ä»æéçºç°å¢ã¿ããªãããã«ç¹ãã£ã¦ããããã¨ããåæã§ã
ãã©ã°ã¤ã³ã§ä½ããã£ã¦ããããtranslation_ja.yml ãä½ãããã¼ã¯ã¼ãã¯ã¢ãã«ã®åã¯ã¾ãã¢ãã«ãããããåã£ã¦ã¨ã£ã¦ããããã¥ã¼æ¹é¢ãå ¨é¨åã£ã¦ãä¸åº¦åããã¦ãI18nã®ç¿»è¨³ã¡ã½ãããããã¯ãã¦ãã®ãã¼ãæ¶ãã¦ãã£ã¦ãªãã¨ãããã
ãã¥ã¼ãæ¸ãæãããã¾ã generate i18n ja ãã¦ããã°è¯ããtranslation_ja.yml ã¯é©å½ã«è¿½å ã¨ãå¤æ´ãã¦ãããããããã¦ãã㯠Rails ã¯èªã¿ç´ãã¦ãããã
ãã¥ã¼ã§ã¯ç´æ¥ã<%=t :key %>ãã¨æ¸ããããã«ãªã£ã¦ããh ã¨ã®ããã¿ã§ã¯ã<%=h t(:key) %>ãããªãæã¯ãã«ãã¼ãã©ããã§ãhtãã¡ã½ãããä½ãã
created_at, updated_at ã«ã©ã ã®ç¿»è¨³ã¯å¿ è¦ã? æ¾ç°ããã¯ãã®äºã¤ã¯ã·ã¹ãã ç¨ã®ã«ã©ã ã§ãã£ã¦ã¦ã¼ã¶ã«è¦ããã¨ãããããªãã ããã¨ãã£ããããã§ãä»ã¯ä¸å¿å ¥ã£ã¦ãã
ãã¥ã¼ã§ã® datetime_select ã¯ã¡ãã£ã¨ç¡æ§ãããæã ãã1æã表è¨ãlã¡ã½ããã®åä½ãCucumberãWebrat ã¨ã®ç¸æ§ãæªãã
ãã¨ãããããåè§ã¹ãã¼ã¹ãå ¥ãã®ãã©ãã«ããããã¨ãã2.3ã§ã¯ãªãã¨ãã