Opening .html.erb files in browser

2019-09-06 18:00发布

Is there a way to open .html.erb files by themselves in the browser. The Rails app I am trying to have a look at is in rails 2.3 and will not run locally on the rails server nor will it run when I give the command script/server.

I would just like to open the individual views in the browser by themselves...is this possible?

2条回答
Evening l夕情丶
2楼-- · 2019-09-06 18:32

You can open them in the browser, but the <% %> and <%= %> tags will get shown as-is instead of executing the Ruby code. These are template files that need to get processed by Rails to fill in data at runtime. Your best bet is TsaiKoga's answer, making a controller action render the template in question.

查看更多
一纸荒年 Trace。
3楼-- · 2019-09-06 18:45

In rails4 you can do it like this:

erb a.html.erb > a.html

Maybe it doesn't work in rails 2.3. If you want to render that view, maybe you can use an action just like users#index and change the code to render it:

render "devise/mailer/a.html.erb", :layout => false
查看更多
登录 后发表回答