[英]how can i access the view page through url in a ruby on rails application using netbeans as ide?
I have created a new ruby on rails project using netbeans as ide. 我使用netbeans作为ide创建了一个新的Rails项目ruby。 after creating an application i create a controller named hello and then view also named hello.
创建应用程序后,我创建一个名为hello的控制器,然后查看也命名为hello。 Now when i try this in url
现在,当我尝试在URL
http://localhost:3000
, I get the homepage. ,我得到了主页。 But when i try this url:-
但是当我尝试这个网址:-
http://localhost:3000/hello/hello
the following error appears:- 出现以下错误:
We're sorry, but something went wrong. 我们很抱歉,但有些不对劲。
We've been notified about this issue and we'll take a look at it shortly. 我们已收到有关此问题的通知,我们将尽快对其进行研究。
can anyone point to me to a solution?? 谁能指出我的解决方案?
Did you make a method hello
in the hello controller? 您是否在hello控制器中创建了方法
hello
? And a route to this method? 以及采用这种方法的途径? Views are made for the methods, not the controller themselves.
视图是针对方法而不是控制器本身的。 The controller name dictates the folder that those views should sit in.
控制器名称决定了这些视图应位于的文件夹。
Examples, really basic ones: 例子,非常基本的例子:
config\\routes.rb config \\ routes.rb
get 'hello/hello' => 'hello#hello'
app\\controllers\\hello_controller.rb app \\ controllers \\ hello_controller.rb
def hello
@hello = 'Hello!'
end
app\\views\\hello\\hello.html.erb app \\ views \\ hello \\ hello.html.erb
<%= @hello %>
Then visit http://localhost:3000/hello/hello
然后访问
http://localhost:3000/hello/hello
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.