Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ssis/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 得到一份工作。而不是我的链接(路径)中的/_Ruby On Rails_Ruby On Rails 3 - Fatal编程技术网

Ruby on rails 得到一份工作。而不是我的链接(路径)中的/

Ruby on rails 得到一份工作。而不是我的链接(路径)中的/,ruby-on-rails,ruby-on-rails-3,Ruby On Rails,Ruby On Rails 3,以上是我的表演动作。所以问题是,如果我用id=2搜索,我应该得到的结果链接是system\u accounts/2,但我得到的是system\u accounts.2。为什么。而不是a/。有什么我错过的吗 如果您严格遵循rails惯例,则应使用系统帐户路径(params[:id])(不带s)。2被解释为格式,因此它将.2附加到url,因为系统帐户路径很可能指向系统帐户控制器的索引操作。删除s以指向“显示”操作 # GET system_accounts/:id def show #

以上是我的表演动作。所以问题是,如果我用id=2搜索,我应该得到的结果链接是system\u accounts/2,但我得到的是system\u accounts.2。为什么。而不是a/。有什么我错过的吗

如果您严格遵循rails惯例,则应使用
系统帐户路径(params[:id])
(不带
s
)。2被解释为格式,因此它将
.2
附加到url,因为
系统帐户路径
很可能指向系统帐户控制器的索引操作。删除s以指向“显示”操作

# GET system_accounts/:id
  def show 
    # If a system account already exists in session, it was found from a search with the account id
    # Otherwise, this is a new search for a system account by the given id
    if params[:id]
      Rails.logger.debug { "Querying for the account with id: #{params[:id]}" }
      response = query_account(CGI.escape(params[:id]))
    if response.is_a?(Net::HTTPSuccess)
        @account = JSON.parse(response.body)
    unless @account.empty?
      redirect_to system_accounts_path(params[:id])        
    end 
    end