I m 在Ruby-On-Rails开发小型应用。 我想从某种角度看待控制器的方法。 这种方法只能使用数据库表格中的一些插入。 这样做的正确方式是什么? 我曾尝试过类似情况,但显然没有执行该方法:
<%= link_to Join , method: join_event %>
I m 在Ruby-On-Rails开发小型应用。 我想从某种角度看待控制器的方法。 这种方法只能使用数据库表格中的一些插入。 这样做的正确方式是什么? 我曾尝试过类似情况,但显然没有执行该方法:
<%= link_to Join , method: join_event %>
联系方式中的方法选择实际上是“吉大港山区”的方法,而不是行动的名称。 在通过《吉大港山区行动计划》删除方案时,这非常有益,因为《危险航程》利用DELETE方法打击销毁行动。
你们需要做的是,为你们的行动开辟了一条道路。 假定其名称为join_event
,在您的路线上添加以下内容。 rb:
match /join_event => controllername#join_event , :as => join_event
确保把控制人姓名改为你使用的控制人名称。 接着,对你的看法作了如下更新:
<%= link_to Join , join_event_path %>
——胎面法是根据路面文件的价值产生的。
为了组织你的守则,你可能希望把这些插入纳入固定模式方法。 因此,如果你有一个称为<代码>MyModel的模型,则你可以这样做。
class MyModel
# ...
def self.insert_examples
MyModel.create(:name => "test")
MyModel.create(:name => "test2")
MyModel.create(:name => "test3")
end
end
Then just execute it in your action via:
MyModel.insert_examples
除了清醒回答外,你还可以把控制器方法暴露在>>>>>《行动监督员:Base:helper_method<<<<:>:
class EventsController < ApplicationController
helper_method :join_event
def join_event(event)
# ...
end
end
But in this case, I think you re best off following his advice and moving this method to the model layer, since it s interacting with the database.
collection_select and select Rails helpers: Which one should I use? I can t see a difference in both ways. Both helpers take a collection and generates options tags inside a select tag. Is there a ...
We ve deployed our rails app to EC2. In our setup, we have two proxies on small instances behind round-robin DNS. These run nginx load balancers for a dynamically growing and shrinking farm of web ...
As part of a web application I need an auth-code to pass as a URL parameter. I am currently using (in Rails) : Digest::SHA1.hexdigest((object_id + rand(255)).to_s) Which provides long strings like : ...
I ve installed RubyCAS-Client version 2.1.0 as a plugin within a rails app. It s working, but I d like to remove the ?ticket= in the url. Is this possible?
I have a these 3 models: class User < ActiveRecord::Base has_many :permissions, :dependent => :destroy has_many :roles, :through => :permissions end class Permission < ActiveRecord::...
I m building an xml document from a hash. The xml attributes need to be in order. How can this be accomplished? hash.to_xml
guys which text editor is good for Rubyonrails? i m using Windows and i was using E-Texteditor but its not free n its expired now can anyone plese tell me any free texteditor? n which one is best an ...
I’m developing an application dedicated to generate statistical reports, I would like that user after saving their stat report they save sql queries too. To do that I wrote the following module: ...