我想删除此部分:
"company.html?#{token_url}&company=#{URI.encode(current_company.trylive_name)}"
但出现错误语法错误,意外'}',期待':'
@iframe_statistics_url = "#{Gaston.amazon.cloudfront.host}/trylive_dashboard/iframe/#{current_user.has_role?(:administrator) ? "companies.html?#{admin_token_url}" : "company.html?#{token_url}&company=#{URI.encode(current_company.trylive_name)}"}"
答案 0 :(得分:0)
您不能在双引号内使用双引号("
)。你需要逃避这些引用:
"Hello, "are you there?" # doesn't make sense in Ruby
"Hello, \"are you there?" # escaped double quotes inside the string
答案 1 :(得分:0)
Try like this
val = current_user.has_role?(:administrator) ? "companies.html?#{admin_token_url}" : "company.html?#{token_url}&company=#{URI.encode(current_company.trylive_name)}"
@iframe_statistics_url = "#{Gaston.amazon.cloudfront.host}/trylive_dashboard/iframe/}#{val}"
Or
g = "https://www.google.co.in/"
q = %[helo #{"world #{g}"}]
=> "helo world https://www.google.co.in/"
Try it
@iframe_statistics_url = %[#{Gaston.amazon.cloudfront.host}/trylive_dashboard/iframe/companies.html?#{current_user.has_role?(:administrator) ? admin_token_url : "#{token_url}&company=#{URI.encode(current_company.trylive_name)}"}]
答案 2 :(得分:0)
@VtrKanna
@iframe_statistics_url = "#{Gaston.amazon.cloudfront.host}/trylive_dashboard/iframe/#{current_user.has_role?(:administrator) ? "companies.html?#{admin_token_url}" : "company.html?#{token_url}&company=#{URI.encode(current_company.trylive_name)}"}"
这很好用 但我的问题只是保留这部分
@iframe_statistics_url = "#{Gaston.amazon.cloudfront.host}/trylive_dashboard/iframe/#{current_user.has_role?(:administrator) ? "companies.html?#{admin_token_url}"}"
这是结果错误