Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/62.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 Rails是在视图中连接字符串和变量的最佳方法_Ruby On Rails_Ruby_Ruby On Rails 3 - Fatal编程技术网

Ruby on rails Rails是在视图中连接字符串和变量的最佳方法

Ruby on rails Rails是在视图中连接字符串和变量的最佳方法,ruby-on-rails,ruby,ruby-on-rails-3,Ruby On Rails,Ruby,Ruby On Rails 3,本质上,我是在做这个比较 request.fullpath == "/contacts/"+current_user.id 将字符串与变量串联以执行类似比较的最佳方法是什么?您可以将其插值为request.fullpath=“/contacts/#{current_user.id}” 始终使用字符串插值,它比快为什么字符串插值比others@wasipeer本例中的字符串连接将创建两个字符串,然后执行连接。插值将只创建一个。我找到了这个长椅,你可以自己试试。 "/contacts/#{curr

本质上,我是在做这个比较

request.fullpath == "/contacts/"+current_user.id

将字符串与变量串联以执行类似比较的最佳方法是什么?

您可以将其插值为
request.fullpath=“/contacts/#{current_user.id}”


始终使用字符串插值,它比
快为什么字符串插值比others@wasipeer本例中的字符串连接将创建两个字符串,然后执行连接。插值将只创建一个。我找到了这个长椅,你可以自己试试。
"/contacts/#{current_user.id}"