[Á°][¼¡][ÈÖ¹æ½ç°ìÍ÷][¥¹¥ì¥Ã¥É°ìÍ÷]

rails:3948

From: Ayako Arakane <arakane@r...>
Date: Tue, 10 Dec 2013 14:16:13 +0900
Subject: [rails:3948] URL¤«¤écontroller̾¤ò¾Ê¤­¤¿¤¤

¹Ó¶â¤È¿½¤·¤Þ¤¹¡£

URL¤«¤écontroller̾¤ò¾Ê¤­¤¿¤¤¤Î¤Ç¤¹¤¬¡¢
¤¤¤¤ÊýË¡¤¬¤¢¤ì¤Ð¶µ¤¨¤Æ失¤Ê¤¤¤Ç¤·¤ç¤¦¤«¡£

¶ñÂÎŪ¤ÊÆâÍƤϰʲ¼¤ÎÄ̤ê¤Ç¤¹¡£

-----------------------------------------------------------------
´Ä¶­¡¡ ruby1.8.7 rails 2.3.16

²¼µ­¤Î¤è¤¦¤Êarticle_categories¤È¤¤¤¦
µ­»ö¤Î¥«¥Æ¥´¥ê¥Æ¡¼¥Ö¥ë¤¬¤¢¤ê¤Þ¤¹¡£

id | category_url
---------------
1 | news
2 | school
3 | blog

¤½¤ì¤Ëɳ¤Å¤¯articles¤È¤¤¤¦¥Æ¡¼¥Ö¥ë¤¬¤¢¤ê¤Þ¤¹¡£

id | category_id | title
-----------------------------
1 | 1 | news¤Îµ­»ö1
2 | 2 | blog¤Îµ­»ö1
3 | 3 | blog¤Îµ­»ö2
4 | 4 | school¤Îµ­»ö1

Ä̾ï¤Ç¤¢¤ì¤Ðarticles¤È¤¤¤¦controller¤ò»ÈÍѤ·¤Æ
¥«¥Æ¥´¥ê¤Ëɳ¤Å¤¯µ­»ö¤òɽ¼¨¤¹¤ëºÝ¤Ï
²¼µ­¤ÎURL¤ÇÂбþ¤Ç¤­¤ë¤«¤È»×¤¤¤Þ¤¹¡£

localhost:3000/articles/:category_url/µ­»öid

Îã¡Ë
localhost:3000/articles/news/1

¤¬¡¢¾åµ­¤Î¡Öarticles¡×¤ÎÉôʬ¤ò¾Ê¤­
²¼µ­¤ÎURL¤Ç¥¢¥¯¥»¥¹¤Ç¤­¤ë¤è¤¦¤Ë¤·¤¿¤¤¤Î¤Ç¤¹¡£

localhost:3000/:category_url/µ­»öid

Îã¡Ë
localhost:3000/news/1
localhost:3000/school/4
localhost:3000/blog/3
¢ªarticles¤Îcontroller¤¬Æ°ºî

¢¨¤¿¤À¤·¤½¤Î¾¤Îcontroller¤Ïº£¤Þ¤ÇÄ̤êÆ°ºî¤µ¤»¤¿¤¤
localhost:3000/other/1 ¢ªotherÍѤÎcontroller¤¬Æ°ºî


article_categories¤ÏưŪ¤Ë´ÉÍý¤·¤¿¤¤¤Î¤Ç
µ­»ö¥«¥Æ¥´¥ê¤¬Áý¤¨¤ë¤´¤È¤Ëroutes.rb¤Ë
Äɲ䷤Ƥ¤¤¯¤³¤È¤ÏÈò¤±¤¿¤¤¤È»×¤Ã¤Æ¤ª¤ê¤Þ¤¹¡£

¸½ºß²¼µ­£²¥Ñ¥¿¡¼¥óÄ´ºº¤·¤Æ¤¤¤Þ¤¹¤¬
¤É¤Á¤é¤â¤¦¤Þ¤¯¤¤¤Ã¤Æ¤¤¤Þ¤»¤ó¡£

­¡
application.controller¤Ë¤Æ
¡Öarticle_categories¡×¤Ë¸ºß¤¹¤ë¤«¤ò¥Á¥§¥Ã¥¯¤·¤Æ
¸ºß¤·¤¿¤éarticles.controller¤Ë½èÍý¤òÅϤ»¤Ê¤¤¤«¡£
¢¨redirect_to¤À¤ÈURL¤¬ÊѤï¤Ã¤Æ¤·¤Þ¤¦¤¿¤áNG¤Ç¤¹¡£
¢¨render¤À¤Èview¤ÏÅϤ»¤ë¤Î¤Ç¤¹¤¬
articles.controller¤ò·Ðͳ¤¹¤ë»ö¤¬¤Ç¤­¤Þ¤»¤ó¤Ç¤·¤¿¡£

­¢
routes.rb¤Ë¤ÆÈÆÍÑŪ¤Ë¤Ç¤­¤Ê¤¤¤«¡£

¾åµ­£²¥Ñ¥¿¡¼¥ó°Ê³°¤Ç¤â¤¤¤¤¤Î¤Ç
²¿¤«²ò·èºö¤Ï¤´¤¶¤¤¤Þ¤¹¤Ç¤·¤ç¤¦¤«¡£

µ¹¤·¤¯¤ª´ê¤¤¤¤¤¿¤·¤Þ¤¹¡£



--
ML: rails@r...
»È¤¤Êý: http://QuickML.com/

[Á°][¼¡][ÈÖ¹æ½ç°ìÍ÷][¥¹¥ì¥Ã¥É°ìÍ÷]

->    3948 2013-12-10 06:16 [arakane@r...        ] URL¤«¤écontroller̾¤ò¾Ê¤­¤¿¤¤           
      3949 2013-12-10 08:13 ¨±[dezawa@a...         ]                                       
      3950 2013-12-11 04:30 ¡¡¨±[arakane@r...        ]