铁路协会帮助
嘿,我做了一个名为图片的脚手架,但现在我需要它有很多标签。 我希望它是这样的,以便您可以执行类似单击“添加标签”然后填写标签,然后单击“添加标签...”之类的操作,这将在图片/新建中进行编辑,也许还会显示。 我不知道如何做到这一点,而且我对 Rails 不太了解,所以如果可以的话,请说清楚。 (也许 Rails 中有一些东西,比如一个按钮,如果你点击它,你就会执行一个函数,即使这样我也不知道如何去做) 我正在使用 Rails 3。
Hey I made a scaffold called pictures, but now I need to it to have many tags.
I want it to be so that you can do something like click add tag then fill in a tag, then click add tag ..., this would be in pictures/new and edit, and maybe show.
I don't have a clue how to do this and I am not that great in rails, so be very clear if you can. (maybe there is something in rails like a button that if you click it you execute a function, even then I'm not sure how to go about this)
I am using rails 3.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这是您需要的东西。:
http://railscasts.com /episodes/196-nested-model-form-part-1
http://railscasts.com/episodes/197-nested-model-form-part-2
This is something you need.:
http://railscasts.com/episodes/196-nested-model-form-part-1
http://railscasts.com/episodes/197-nested-model-form-part-2
Kevin,
我认为第一个任务是在这里阅读 Rails ActiveRecord 关联:
http://guides.rubyonrails。 org/association_basics.html
一旦你有了正确的关联,我就会在你的路由文件中将标签作为图片的子资源。这将允许您使用 /pictures/{id}/tags 等路由对 :tags 进行 POST
Kevin,
I think task number one is to read up on Rails ActiveRecord associations here:
http://guides.rubyonrails.org/association_basics.html
Once you have your associations right, I would make tags a sub-resource of pictures in your routes file. This would allow you to do a POST to :tags with a route like /pictures/{id}/tags