简体   繁体   English

如何使用NetBeans作为ide通过Rails应用程序中的ruby通过URL访问查看页面?

[英]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.

相关问题 如何使用netbeans作为IDE将localhost:3000重定向到ruby on rails上的特定页面? - How to redirect localhost:3000 to a specific page in ruby on rails using netbeans as an IDE? 如何配置 VS Code 以中断 Rails 应用程序中的任何异常? (使用 ruby-debug-ide 和 debase) - How can I configure VS Code to break on any exception in a Rails application? (Using ruby-debug-ide and debase) Ruby on Rails:如何通过 ngrok 访问 Action Cable? - Ruby on Rails: How can I access Action Cable through ngrok? 无法从NetBeans IDE运行Ruby on Rails应用程序 - Cannot Run Ruby on Rails application from NetBeans IDE 如何向我的 Ruby on Rails 应用程序添加新视图? - How can I add a new view to my Ruby on Rails application? 如何从外部从Ruby on Rails应用程序访问数据? - How can I access data from a Ruby on Rails application externally? 如何在RubyMine IDE中的Rails应用程序上运行ruby - How to run ruby on rails application in RubyMine IDE 如何使用capistrano将ruby on rails应用程序部署到mochahost? - How can I deploy ruby on rails application to mochahost using capistrano? 如何在Rails中的ruby中呈现网址 - how can I render a url in ruby on rails 我可以在Windows中使用NEtbeans IDE使用rails3吗? - Can I work with rails3 in Windows with NEtbeans IDE?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM