Ruby on rails 得到一份工作。而不是我的链接(路径)中的/
以上是我的表演动作。所以问题是,如果我用id=2搜索,我应该得到的结果链接是system\u accounts/2,但我得到的是system\u accounts.2。为什么。而不是a/。有什么我错过的吗 如果您严格遵循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 #
系统帐户路径(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