2013-02-25 57 views
0

我有去的路線:GET /api/:api_version/publishers/:id(.:format) {:controller=>"api/publishers", :action=>"show"}如何在Rails中的控制器中查看show函數的功能?

所以我彈出打開apipublishers_controller,它看起來:

# Provides access to publisher information 
class Api::PublishersController < Api::BaseResourceController 
    inherit_resources 
    respond_to_data_formats 

    before_filter :find_publisher 
    before_filter :require_publisher_login, :only => :authenticate 

    actions :show 

    # Note: We remove App scope from cache path, since Publisher info should be cached across all apps 
    caches_action :show, :login, :cache_path => lambda {|c| {:version => c.send(:publisher_version), :model_version => Publisher.cache_config.version}}, :expires_in => 60.seconds 

    # Action redirects the top frame to the publisher's site (for the user to log in) 
    def login 
    # Prevent infinite loop where the page redirects to itself. 
    raise ArgumentError, 'Publisher website url is not configured' if @publisher.website_url.blank? 
    end 

    def authenticate 
    respond_with(@publisher) 
    end 

    private 

    def find_publisher 
     params[:publisher_id] = params[:id] 
     super 
    end 

    def publisher_version 
     @publisher.lock_version 
    end 

end 

沒有show功能,所以我怎麼能看到什麼呢?

回答

2

該課程繼承show方法,推測從Api::BaseResourceController開始。如果我必須打賭,我猜Api::BaseResourceController使用inherited_resources或類似的東西,它只是假設show方法應該做一個非常典型的事情:找到記錄並使用可用的模板顯示它。

+0

我想我試圖找到那個模板..在哪裏看任何想法? – Shamoon 2013-02-25 18:48:39

相關問題