Reputation: 7622
routes.rb:
match 'first/#!/:name' => 'first#first'
first_controller.rb:
class FirstController < ApplicationController
def first
@name = params[:name]
end
end
But the @name
variable is nil when I render the url: http://localhost:3000/first/#!/sayuj
Please help
Upvotes: 1
Views: 2987
Reputation: 9216
Jits is correct that the # in the url will drop the rest of the url, also, I believe your route is incorrect, it should look like:
match 'first/:name', :to => 'first#first'
documentation is at Engine yard rails 3 routes.
Upvotes: 1
Reputation: 9728
Anything after the first #
in the URL is not (usually) sent back to the server; it's used on client side only.
So the URL http://localhost:3000/first/#!/sayuj
in the client will actually call the URL http://localhost:3000/first/
on server side.
See the following posts for more info:
Upvotes: 10