Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ruby-on-rails-3/4.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 3 如何让“照片”url(…)起作用?_Ruby On Rails 3 - Fatal编程技术网

Ruby on rails 3 如何让“照片”url(…)起作用?

Ruby on rails 3 如何让“照片”url(…)起作用?,ruby-on-rails-3,Ruby On Rails 3,photo_urlPhoto.first,:host=>“foobar”返回http://foobar/photos/2vig0 . 我如何使用类似“photo”的东西做同样的事情呢?\u urlPhoto.first,:host=>foobar' 我是否需要执行类似“photo”.constantize.\u urlPhoto.first,:host=>“foobar”将字符串的两个部分连接在一起后,就可以使用send调用方法 假设@fn包含字符串photo: 或者,可能更清楚: send(

photo_urlPhoto.first,:host=>“foobar”返回http://foobar/photos/2vig0 .

我如何使用类似“photo”的东西做同样的事情呢?\u urlPhoto.first,:host=>foobar'

我是否需要执行类似“photo”.constantize.\u urlPhoto.first,:host=>“foobar”

将字符串的两个部分连接在一起后,就可以使用send调用方法

假设@fn包含字符串photo:

或者,可能更清楚:

send("photo" + "_url", Photo.first, :host => 'foobar')
你的网址呢

send("photo" + "_url", Photo.first, :host => 'foobar')