我正在尝试创建新的主持人:
<%= link_to 'add new user', new_admin_moderator_path %>
namespace :admin do
resources :moderator
end
def new
@moderator = Moderator.new
end
def create
@moderator = Moderator.new(moderator_params)
if @moderator.save
redirect_to admin_moderator_index_url
else
render 'new'
end
end
private
def moderator_params
params.require(:moderator).permit(:id, :fullname, :username, :password)
end
<h1>Create new</h1>
<%= form_for [:admin , @moderator] do |u| %>
<p>
<%= u.lable :fullname %>
<%= u.text_field :fullname %>
</p>
<p>
<%= u.lable :username %>
<%= u.text_field :username %>
</p>
<p>
<%= u.lable :password %>
<%= u.password_field :password %>
</p>
<p>
<%= u.submit %>
</p>
<% end %>
它显示如下错误:
views/admin/moderator/new.erb where line #2 raised:
NoMethodError in Admin::Moderator#new
undefined method `admin_moderators_path' for #<#<Class:0x607ce90>:0x907a0d0>
Did you mean? admin_moderator_path,
admin_moderator_index_path,
admin_moderator_url
Extracted source (around line #2):
<h1>Create new</h1> <%= form_for [:admin , @moderator] do |u| %> <p> <%= u.lable :fullname %> <%= u.text_field :fullname %> </p>
答案 0 :(得分:1)
在您的new.html.erb
中更改此行create table Pipeline
(
ID int identity
, Received_Date Date
, Received_Count Int
)
Insert Into Pipeline
select '01/01/2018', 75 + (RAND() * 50)
union all select '01/15/2018', 75 + (RAND() * 50)
union all select '02/01/2018', 75 + (RAND() * 50)
union all select '02/15/2018', 75 + (RAND() * 50)
union all select '03/01/2018', 75 + (RAND() * 50)
union all select '03/15/2018', 75 + (RAND() * 50)
union all select '04/01/2018', 75 + (RAND() * 50)
union all select '04/15/2018', 75 + (RAND() * 50)
union all select '05/01/2018', 75 + (RAND() * 50)
union all select '05/15/2018', 75 + (RAND() * 50)
union all select '06/01/2018', 75 + (RAND() * 50)
union all select '06/15/2018', 75 + (RAND() * 50)
select * from Pipeline -- so you can see the values you got
select
P1.Received_Date
, (Select Sum(P2.Received_Count)
from Pipeline as P2
Where P2.Received_Date > DateAdd(MONTH, -3, P1.Received_Date)
and P2.Received_Date <= P1.Received_Date
) As Pipeline_Total
from Pipeline as P1