rails:3949
From: dezawa <dezawa@a...>
Date: Tue, 10 Dec 2013 16:13:10 +0900
Subject: [rails:3949] Re: URL¤«¤écontroller̾¤ò¾Ê¤¤¿¤¤
¤Á¤ã¤ó¤È¥Æ¥¹¥È¤Ï¤·¤Æ¤¤¤Þ¤»¤ó¤¬ > ¢ > routes.rb¤Ë¤ÆÈÆÍÑŪ¤Ë¤Ç¤¤Ê¤¤¤«¡£ routes.rb¤Ë¤Æ ActionController::Routing::Routes.draw do |map| category_urls = ArticleCategorie.all.map(&:category_url) category_urls.each{|category| map.connect "/#{category}/:id" , :controller => :articles, :action => category } ¤Ç¤É¤¦¤«¤Ê¤¡¡£ ¡Öblock¤ÎºÇ½é¤Ç DB¤Ë¥¢¥¯¥»¥¹¤·¤Æ¤â¥¨¥é¡¼¤Ë¤Ê¤é¤º¤Ë¥µ¡¼¥Ð¤¬ Ω¤Á¾å¤¬¤ë¡×½ê¤Þ¤Ç¤Ï»î¤·¤Þ¤·¤¿¡£ ½ÐÂô PS ¤Ê¤ó¤«ÊѤ«¤Ê¤¡ users = User.all.map{ |user| [user.id,user.login]} users.each{|id,login| map.connect "/#{login}" , :controller => "users", :action => :show, :id => id } ¤Ç¡¢ localhost:3000/dezawa ¤Ç¥¢¥¯¥»¥¹¤·¤Æ¤ß¤ë¤È¡¢controller¤Ë¤Ï ÆϤ¤¤Æ¤¤¤ë¤Î¤Ç¤¹¤¬ Processing UsersController#show ( ... ) [GET] Parameters: {"id"=>1} : Rendering template within layouts/application Rendering users/show : ActionView::TemplateError (Called id for nil, which would mistakenly be 4 -- if you really wan ted the id of nil, use object_id) on line #2 of app/views/users/show.html.erb: 1: ¥æ¡¼¥¶ÊÌÀßÄêɽ 2: <% form_for(@user) do |f| -%> 3: <%= f.error_messages %> 4: <% end %> 5: <%= link_to '½¤Àµ', edit_user_path(@user) %> @user ¤¬ nil¤Ã¤Ý¤¤ localhost:3000/users/1 ¤Ê¤é´üÂÔÄ̤ê¤Îɽ¼¨¡£ Rendering¤Þ¤Ç¤Ï log¤ÏƱ¤¸¤Ê¤Î¤Ë¡£ »î¤·¤ÆÂÌÌܤÀ¤Ã¤¿¤é˺¤ì¤Æ¤¯¤À¤µ¤¤¡£ -- 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... ]