user1936635
user1936635

Reputation: 45

how can I render a url in ruby on rails

I have this in my controller but don't work (when I set redirect_to page1_url works well):

render page1_url

in my routes.rb I have a url path:

get "main/page1"
post "main/page1"
match "page1" => 'main#page1'

when I change render in my controller so

render 'main/page1' 

works well but the images in the view not appear, please help

Upvotes: 0

Views: 133

Answers (1)

miked
miked

Reputation: 4509

You need to specify a name for the route helper using ":as". This will give you the page1_url helper.

 match "page1" => 'main#page1', :as=>"page1"

See: naming routes in the docs

Upvotes: 1

Related Questions