制作一个控制器

发布于 2024-11-25 15:35:10 字数 149 浏览 1 评论 0原文

我有一个用 html/css 制作的网站。我刚刚开始学习 RubyOnRails,我想将我的 URL 链接转换为控制器。所以我做了一个新的控制器,现在我不知道如何继续。我有一个电子邮件按钮,我为 mail_controller.rb 创建了一个控制器,并希望它链接到我的电子邮件地址。

I've this website I made in html/css. And I'm just starting to learn RubyOnRails and I'd like to turn my URL links into controllers. So I made a new controller, and now I don't know how to go forward. I got an email button which I made a controller for mail_controller.rb and want it to link to my email adress.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

九八野马 2024-12-02 15:35:10

您不仅需要控制器,还需要其路由。
确保您在 config/routes.rb 文件中有一个将您想要的 url 与您创建的控制器进行映射的路由。

也许您可能想查看指南: http://guides.rubyonrails.org/getting_started.html

You need not only the controller, but also the routes for that.
Make sure you have on the config/routes.rb file a route mapping the url you want with the controller you made.

Perhaps you may want to take a look at the guides: http://guides.rubyonrails.org/getting_started.html

蝶…霜飞 2024-12-02 15:35:10

如果您只想链接电子邮件,则不一定需要控制器。您可以这样做:

link_to 'Click to email me', 'mailto: [email protected]'

它将打开用户的邮件客户端以将邮件发送到给定的电子邮件地址。如果您想使用操作邮件程序,那么我建议您阅读:

http://guides.rubyonrails.org/action_mailer_basics .html

If you just want to link your email, you don't necessarily need a controller for that. You can just do:

link_to 'Click to email me', 'mailto: [email protected]'

and it will open the user's mail client to sent a mail to the given email address. If you wanted to use action mailer, then I suggest you read:

http://guides.rubyonrails.org/action_mailer_basics.html

巨坚强 2024-12-02 15:35:10

您似乎刚刚开始使用 Rails。我强烈建议你买一本书来开始。对于 Rails 新手来说,Agile Rails 可能是一个非常好的选择。

它将帮助您更好地理解 MVC 模型在 Rails 中如何工作,如何设置控制器、模型、路由等。此时,当您开始时,您需要更好地了解 Rails 的整体工作原理,最好的方法是阅读一本书,或者甚至更好,按照 Sebastian Martinez 的说法,阅读在线指南。

You seem like you are just starting with Rails. I would highly recommend that you get a book to start with that. Agile Rails is probably a very good choice for newcomers in Rails.

It will help you better understand how the MVC model works in Rails, how to set up controllers, models, routes and more. At this point when you start, you need to have a better understand of how Rails works overall and the best way to do that is by reading a book or, maybe even better, do as Sebastian Martinez says, read the online guides.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文