0
的routes.rbsimple_navigation寶石和軌道3.0.9
PASFramework::Application.routes.draw do |map|
resources :users do
collection do
get :index
get :edit
post :update
get :show
end
end
root :to => 'users#index'
end
============================== ==================================== navigation.rb
# Configures your navigation
SimpleNavigation::Configuration.run do |navigation|
navigation.items do |primary|
primary.item :users, 'Welcome User', root_path do |users|
users.item :edit, 'Edit Profile', edit_users_path
end
end
端
================================================ ==================
User_controll呃
class UsersController < ApplicationController
def index
user = current_facebook_user.fetch
@u = User.find_by_facebook_id(user.id)
if @u.nil?
@u = User.find_or_create_by_facebook_id(user.id)
@u.update_attributes(:first_name => current_facebook_user.first_name,
:last_name => current_facebook_user.last_name)
gflash :notice => "Welcome, #{current_facebook_user.name} "
else
gflash :notice => "Welcome back, #{current_facebook_user.first_name} #{current_facebook_user.last_name}"
end
return
rescue Exception
logger.info "Problem"
logger.error($!)
top_redirect_to auth_url
end
def show
end
def edit
user = current_facebook_user.fetch
@user = User.find_all_by_facebook_id(user.id)
end
def update
user = current_facebook_user.fetch
@user = User.find_all_by_facebook_id(user.id)
if @user.update_attributes(:first_name => params[:first_name],
:last_name => params[:last_name])
redirect_to user_path, :notice => t('users.update_success')
else
render :action => 'edit'
end
end
end
========================================== ================================
該菜單創建得非常好,並感謝這個真棒插件。但是當我點擊編輯用戶時,我收到一個錯誤:
ActionView::Template::Error (No route matches {:action=>"show", :controller=>"users"}):
有人可以幫我解決嗎?有人可以解釋我爲什麼在routes.rb資源用戶只是不工作,而不是集合的東西?
在此先感謝。
感謝您的回答。但我仍然有同樣的問題。我做了你的建議,但仍然:2011-06-27T03:10:19 + 00:00 app [web.1]:ActionView :: Template :: Error(無路線匹配{:action =>「show」,:controller =>「users」}): – glarkou
你能試試這個路徑嗎?<%= link_to user.name,user%>'並確保'user'是視圖中的局部變量,或<%= link_to @ user.name ,@user%>'或者你可以訪問用戶對象。 – s84
你可以發佈你如何生成你的鏈接。 – s84