ruby on rails route params in controller

Say*_*yuj 1 routes ruby-on-rails

routes.rb中:

match 'first/#!/:name' => 'first#first'
Run Code Online (Sandbox Code Playgroud)

first_controller.rb:

class FirstController < ApplicationController
  def first
    @name = params[:name]
  end
end
Run Code Online (Sandbox Code Playgroud)

但是@name当我渲染url时,变量为nil:http:// localhost:3000/first /#!/ sayuj

请帮忙

Jit*_*its 10

#URL中第一个之后的任何内容都不会(通常)发送回服务器; 它仅在客户端使用.

因此,http://localhost:3000/first/#!/sayuj客户端中的URL实际上将调用http://localhost:3000/first/服务器端的URL .

有关详细信息,请参阅以下帖子: