2016-03-02 148 views
1

我想删除这部分: "company.html?#{token_url}&company=#{URI.encode(current_company.trylive_name)}"但错误出现语法错误,意外 '}',希望 ':'语法错误,意外 '}',期待 ':' Rails的

@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

您不能在双引号内使用双引号(")。你需要逃避这些报价:

"Hello, "are you there?" # doesn't make sense in Ruby 
"Hello, \"are you there?" # escaped double quotes inside the string 
0

尝试这样

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}" 

或者

g = "https://www.google.co.in/" 

q = %[helo #{"world #{g}"}] 

=> "helo world https://www.google.co.in/" 

试试吧

@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)}"}] 
+0

@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_name)}”}“ –

+0

您需要单行吗? – VtrKanna

+0

我在其他请点击以上评论 –

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}"}" 

这是导致错误

+0

你应该编辑你的问题,而不是回答:) – niceman

相关问题