def edit
respond_to do |format|
format.html {
@prev_template = false
@new_custom_field_values = getNewCustomField
setup
findWkTE(@startday)
@editable = @wktime.nil? || @wktime.status == 'n' || @wktime.status == 'r'
@entries = findEntries()
set_project_issues(@entries)
if @entries.blank? && !params[:prev_template].blank?
@prev_entries = prevTemplate(@user.id)
if !@prev_entries.blank?
set_project_issues(@prev_entries)
@prev_template = true
end
end
render :layout => !request.xhr?
}
format.api {
}
end
end
我猜测这块代码是某个修改页面显示相关的内容,我想对该修改页面调用的数据库查询结果集做修改调整,以上这段代码中没看到直接引用数据库查询结果,唯独看到这句“@prev_entries = prevTemplate(@user.id)”中prevTemplate
函数定义中有 sql 语句,但是修改了相应的 sql 语句后,返回的查询结果集还是没有变化。
对这块代码理解的不深,大家能帮我看看,可能问题在哪里么?
set_project_issues(@entries)
if @entries.blank? && !params[:prev_template].blank?
@prev_entries = prevTemplate(@user.id)
if !@prev_entries.blank?
set_project_issues(@prev_entries)
@prev_template = true
end
end
@juanito,不好意思,对 ruby 这门技术还不太了解,你说的“Markdown 語法幫助”,之前不知道, 在你说回复框后,我看到这行字“按“M”键查看更多 帮助。”
我按 m 没反应,点击“帮助”超链接,弹出来的框是偏移的,文字内容看不完整。
我说真心的 楼主先看看书呗... 这样折磨自己多难受呢... 废话说完了 楼主再贴一下 prevTemplate 函数的内容 和 view 里面的代码吧 只有 controller 没法分析的
@zj0713001 谢谢你的建议,之前我在网上也看了一些相关初级入门文档,因为有代码要改,想边调试边学习,所以也没有很充足的全面学习。对 ruby 这门语言是零基础,先前也不知道好的书和资料哪里有,加上英文不太好,看网上的资源悟性不高吧 :$
**prevTemplate函数**
def prevTemplate(user_id)
prev_entries = nil
noOfWeek = Setting.plugin_redmine_wktime['wktime_previous_template_week']
if !noOfWeek.blank?
entityNames = getEntityNames
**这段是我修改后的sql语句,增加了一个project_id 项目id的结果集删选**
sqlStr = "select t.* from " + entityNames[1] + " t" +
" inner join (select " + getDateSqlString('spent_on') + " as startday" +
" from " + entityNames[1] + " where user_id = " + user_id.to_s +
" group by startday order by startday desc limit " + noOfWeek.to_s + ") as v" +
" on " + getDateSqlString('t.spent_on') + " = v.startday where user_id = " + user_id.to_s +
" and project_id=#{@selected_pro_id}"+
" order by t.project_id, t.issue_id, t.activity_id"
=begin
**这段是原始最初的sql语句**
##oldsql
sqlStr = "select t.* from " + entityNames[1] + " t" +
" inner join (select " + getDateSqlString('spent_on') + " as startday" +
" from " + entityNames[1] + " where user_id = " + user_id.to_s +
" group by startday order by startday desc limit " + noOfWeek.to_s + ") as v" +
" on " + getDateSqlString('t.spent_on') + " = v.startday where user_id = " + user_id.to_s +
" order by t.project_id, t.issue_id, t.activity_id"
=end
prev_entries = TimeEntry.find_by_sql(sqlStr)
end
prev_entries
end
修改页面的 view 嵌套了好几个页面,我把自己分析的觉得是主要的一张.erb 文件帖上来。
<%
@wday_index = 1
@trOpen = false
@row = 0
@total_hours = 0.0
thours = nums = Array[0.0, 0.0, 0.0, 0.0,0.0, 0.0, 0.0]
prev_entry = nil
entry = nil
currencySym = ""
%>
<div class="wk-contextual">
<% if @editable %>
<%= link_to l(:button_add_row), "javascript:addRow();projectChanged(document.getElementsByName('time_entry[][project_id]'),0);", :class => 'icon icon-time-add' %>
<% end %>
</div>
<table id="issueTable" class="list time-entries">
<thead>
<tr>
<%= render :partial => 'issue_header'%>
</tr>
</thead>
<tbody>
<% unless entries.blank?
col_values = []
matrix_values = []
weeklyHash = getWeeklyView(entries, controller.getUnitLabel, false)
weeklyHash.each do |key, matrix|
matrix.each do |rows|
issueWritten = false
rows.each.with_index do |entry, i|
%>
<% if !entry.blank? %>
<% if !issueWritten %>
<% # this is a new Row %>
<% # close the previously opened row first %>
<%= render :partial => 'edit_hours', :locals => {:entry => nil, :isTemplate => false,
:padAt => 'end', :padTill => 8}%>
<%= render :partial => 'edit_issues2', :locals => {:entry => entry, :isTemplate => false}%>
<% issueWritten = true %>
<% end %>
<% # fill the days till the current day %>
<%= render :partial => 'edit_hours', :locals => {:entry => nil, :isTemplate => false,
:padAt => 'begin', :padTill => i+1}%>
<%= render :partial => 'edit_hours', :locals => {:entry => entry, :isTemplate => false,
:padAt => 'begin', :padTill => i+2}%>
<% thours[i] += entry.hours unless @prev_template%>
<% @total_hours += entry.hours unless @prev_template%>
<% currencySym = controller.getUnit(entry) %>
<% end %>
<% end %>
<% # write only the firt row for previous week template
break if @prev_template %>
<% end %>
<% end %>
<% else -%>
<% # if there are no entries, put an empty row%>
<% currencySym = controller.getUnit(nil) %>
<%= render :partial => 'edit_issues2', :locals => {:entry => nil, :isTemplate => false}%>
<% end %>
<% # pad any incomplete days %>
<%= render :partial => 'edit_hours', :locals => {:entry => nil, :isTemplate => false,
:padAt => 'end', :padTill => 8}%>
<!-- row for putting the total -->
<tr>
<td class="project"></td>
<td class="issue"></td>
<td class="activity"></td>
<td class="comments"></td>
<td ></td> <!-- for currency -->
<td></td>
<td></td>
<% thours.each_with_index do |th,i| %>
<td align="center"><%= currencySym %> <span id=<%= "day_total_#{i+1}" %>><%= ("%.2f" % th) %></span></td>
<% end %>
<td>
<b> <%= l(:label_total) %>: <%= currencySym %> <span id="total_hours"><%= ("%.2f" % @total_hours) %></span></b>
<%=h hidden_field_tag('total', ("%.2f" % @total_hours) ) %>
<%=h hidden_field_tag('unit', currencySym) %>
</td>
</tr>
<% if controller.showWorktimeHeader %>
<!-- Remaining Hours -->
<%= render :partial => 'worktime_header', :locals => {:str => 'remaining_hours', :isEditable => false, :value => '0.0'}%>
<% end %>
</tbody>
</table>
<% if @wktime.nil? || @wktime.status == 'n' || @wktime.status == 'r' %>
<%= submit_tag l(:button_save), :id => 'wktime_save', :name => 'wktime_save', :disabled => !(@row > 0)%>
<% if !Setting.plugin_redmine_wktime[:wktime_use_approval_system].blank? &&
Setting.plugin_redmine_wktime[:wktime_use_approval_system].to_i == 1 %>
<%= submit_tag l(:button_submit),:id => 'wktime_submit', :name => 'wktime_submit', :onclick => "return validateMinhour('#{controller.minHour}','#{getNonWorkingDayColumn()}');" , :disabled => !(@row > 0)%>
<% end %>
<% end %>
<% if !Setting.plugin_redmine_wktime[:wktime_use_approval_system].blank? &&
Setting.plugin_redmine_wktime[:wktime_use_approval_system].to_i == 1 %>
<% if !@wktime.nil? && @wktime.status == 's' %>
<%= submit_tag l(:button_wk_unsubmit), :name => 'wktime_unsubmit', :disabled => !(@row > 0)%>
<% if !@manage_projects.blank? &&
(@user.id != User.current.id ||(!Setting.plugin_redmine_wktime[:wktime_own_approval].blank? && Setting.plugin_redmine_wktime[:wktime_own_approval].to_i == 1)) %>
<%= submit_tag l(:button_wk_approve), :name => 'wktime_approve', :disabled => !(@row > 0)%>
<%=h hidden_field_tag('wktime_notes', "") %>
<% # the jquery dialog box doesn't port the reject button value%>
<%=h hidden_field_tag('hidden_wk_reject', "") %>
<%= submit_tag l(:button_wk_reject), :name => 'wktime_reject', :disabled => !(@row > 0),
:onclick => "return showNotes();" %>
<% end %>
<% elsif !@wktime.nil? && @wktime.status == 'a' %>
<% if !@manage_projects.blank? && (@user.id != User.current.id ||(!Setting.plugin_redmine_wktime[:wktime_own_approval].blank? && Setting.plugin_redmine_wktime[:wktime_own_approval].to_i == 1)) %>
<%= submit_tag l(:button_wk_unapprove), :id => 'wktime_unapprove', :name => 'wktime_unapprove'%>
<% end %>
<% end %>
<% end %>
<div class="splitcontentright">
<div class="contextual">
<% if @editable %>
<%= link_to l(:button_add_row), "javascript:addRow();projectChanged(document.getElementsByName('time_entry[][project_id]'),0);", :class => 'icon icon-time-add' %>
<% end %>
</div>
</div>
<%= context_menu time_entries_context_menu_path %>
#18 楼 @zj0713001 对于第一,我在一个 edit.html.erb 代码里加了这行代码,是不是就能传递参数过去?我查看 edit 页面的源代码,是能得到我要的 project_id 值的。
<%= render :partial => 'row_template' %>
<!--表单头-->
<%= form_tag({:controller => controller.controller_name, :action => 'update'}, :method => :post, :id => 'wktime_edit') do %>
<h2><%= l(:label_wktime) %></h2>
<%=h hidden_field_tag('tab', "#{controller_name}") %>
<!--add project_id Parameter-->
<%=h hidden_field_tag('project_id', "#{@selected_project.id}") %>
<%= render :partial => 'edit_header' %>
对于第二。我还不理解 :$
#20 楼 @zj0713001 你说“那你的代码里就得写是 @selected_pro.id 而不是 @selected_pro_id”
你的意思是我在 prevTemplate 函数里面 " and project_id=#{@selected_pro_id}"+
这句话应该这样? " and project_id="+ @selected_pro_id+
#24 楼 @zj0713001 第二个问题,凭我目前的能力还欠缺:( 首先感谢你这么热心的帮助我,弱弱的问一下,你用聊天工具不?能否求一个,方便我向你进一步请教。
#26 楼 @zj0713001 问个问题,这段代码中 set_project_issues(@xxxx)
,依你看是做什么用?
set_project_issues(@entries)
if @entries.blank? && !params[:prev_template].blank?
@prev_entries = prevTemplate(@user.id)
if !@prev_entries.blank?
set_project_issues(@prev_entries)
@prev_template = true
end
end
还有第二个问题,我在之前我贴出来的那个 view 的 erb 文件中看到这段代码,是不是就是引用@prev_template
的地方
<% if !entry.blank? %>
<% if !issueWritten %>
<% # this is a new Row %>
<% # close the previously opened row first %>
<%= render :partial => 'edit_hours', :locals => {:entry => nil, :isTemplate => false,
:padAt => 'end', :padTill => 8}%>
<%= render :partial => 'edit_issues2', :locals => {:entry => entry, :isTemplate => false}%>
<% issueWritten = true %>
<% end %>
<% # fill the days till the current day %>
<%= render :partial => 'edit_hours', :locals => {:entry => nil, :isTemplate => false,
:padAt => 'begin', :padTill => i+1}%>
<%= render :partial => 'edit_hours', :locals => {:entry => entry, :isTemplate => false,
:padAt => 'begin', :padTill => i+2}%>
<% thours[i] += entry.hours unless @prev_template%>
<% @total_hours += entry.hours unless @prev_template%>
<% currencySym = controller.getUnit(entry) %>
<% end %>
<% end %>
<% # write only the firt row for previous week template
break if @prev_template %>
<% end %>
<% end %>
#29 楼 @zj0713001 收到你的回复,感动 ing,很感谢你在忙碌的工作中这么热心的帮助我,这块东西对于初学的我而言,感觉牵涉的东西纵横交错,有不少想请教的,在这里都贴出来么怕影响版面,所以之前问你是否有其他联系方式,方便进一步请教。
#31 楼 @zj0713001 先请教一下,根据你前几天回的帖,我调试了一下,发现你说的没错。edit 这段代码里面
def edit
respond_to do |format|
format.html {
@prev_template = false
@new_custom_field_values = getNewCustomField
setup
findWkTE(@startday)
@editable = @wktime.nil? || @wktime.status == 'n' || @wktime.status == 'r'
@entries = findEntries()
set_project_issues(@entries)
'这个if条件里面的内容没有执行,因为 @entries结果集非空。
===============================================
if @entries.blank? && !params[:prev_template].blank?
@prev_entries = prevTemplate(@user.id)
if !@prev_entries.blank?
set_project_issues(@prev_entries)
@prev_template = true
end
end
================================================
render :layout => !request.xhr?
}
format.api {
}
end
end
我想查看 @entries结果集调用的 sql 语句,几天都没找到门,看到@entries集合调用了 finEntries 方法但是也没找到 sql 语句,我自己调试加了一个@selected_project.id参数,结果报错。又看了 findEntriesByCond 方法,看到它就完全不懂啥意思了:$
def findEntries
setup
# cond = getCondition('spent_on', @user.id, @startday, @startday+6, @selected_project.id)
cond = getCondition('spent_on', @user.id, @startday, @startday+6)
findEntriesByCond(cond)
end
def findEntriesByCond(cond)
TimeEntry.find(:all, :conditions => cond,
:order => 'project_id, issue_id, activity_id, spent_on')
end
#36 楼 @zj0713001 你说的 guides 是什么?,没找到。
我找的 log 里面看不出 sql,麻烦你帮我看看
Connecting to database specified by database.yml OpenIdAuthentication.store is nil. Using in-memory store. Creating scope :sorted. Overwriting existing method Group.sorted. Creating scope :sorted. Overwriting existing method User.sorted. Started GET "/wktime/index?utf8=%E2%9C%93&getusers_url=%2Fwktime%2Fgetusers&tab=wktime&project_id=2&user_id=0&status=all&period_type=1&period=current_year" for 127.0.0.1 at 2013-07-17 13:26:01 +0800 Processing by WktimeController#index as HTML Parameters: {"utf8"=>"✓", "getusers_url"=>"/wktime/getusers", "tab"=>"wktime", "project_id"=>"2", "user_id"=>"0", "status"=>"all", "period_type"=>"1", "period"=>"current_year"} Current user: xwj (id=5) DEPRECATION WARNING: Paginator no longer takes a controller instance as the first argument. Remove it from #new arguments. (called from initialize at C:/Sites/redmine-2.3.0/lib/redmine/pagination.rb:28) DEPRECATION WARNING: Paginator#items_per_page will be removed. Use #per_page instead. (called from items_per_page at C:/Sites/redmine-2.3.0/lib/redmine/pagination.rb:94) DEPRECATION WARNING: Paginator#current will be removed. Use .offset instead of .current.offset. (called from current at C:/Sites/redmine-2.3.0/lib/redmine/pagination.rb:99) Rendered plugins/redmine_wktime/app/views/wktime/_tab_content.html.erb (0.0ms) Rendered plugins/redmine_wktime/app/views/wktime/_tab_content.html.erb (0.0ms) Rendered common/_tabs.html.erb (15.6ms) Rendered plugins/redmine_wktime/app/views/wktime/_date_range.html.erb (0.0ms) Rendered plugins/redmine_wktime/app/views/wktime/_list.html.erb (15.6ms) Rendered plugins/redmine_wktime/app/views/wktime/_te_index.html.erb (109.4ms) Rendered plugins/redmine_wktime/app/views/wktime/index.html.erb within layouts/base (265.6ms) Completed 200 OK in 2078ms (Views: 359.4ms | ActiveRecord: 46.9ms) Started GET "/wktime/edit?project_Id=2&startday=2013-04-21&tab=wktime&user_id=3" for 127.0.0.1 at 2013-07-17 13:26:09 +0800 Processing by WktimeController#edit as HTML Parameters: {"project_Id"=>"2", "startday"=>"2013-04-21", "tab"=>"wktime", "user_id"=>"3"} Current user: xwj (id=5) Rendered plugins/redmine_wktime/app/views/wktime/_wktime_cf_in_row.erb (0.0ms) Rendered plugins/redmine_wktime/app/views/wktime/_edit_issues2.html.erb (15.6ms) Rendered plugins/redmine_wktime/app/views/wktime/_edit_hours.html.erb (0.0ms) Rendered plugins/redmine_wktime/app/views/wktime/_row_template.html.erb (15.6ms) Rendered plugins/redmine_wktime/app/views/wktime/_edit_header.html.erb (0.0ms) Rendered plugins/redmine_wktime/app/views/wktime/_wktime_cf_in_row_header.html.erb (0.0ms) Rendered plugins/redmine_wktime/app/views/wktime/_issue_header.html.erb (15.6ms) Rendered plugins/redmine_wktime/app/views/wktime/_edit_hours.html.erb (0.0ms) Rendered plugins/redmine_wktime/app/views/wktime/_wktime_cf_in_row.erb (0.0ms) Rendered plugins/redmine_wktime/app/views/wktime/_edit_issues2.html.erb (0.0ms) Rendered plugins/redmine_wktime/app/views/wktime/_edit_hours.html.erb (0.0ms) Rendered plugins/redmine_wktime/app/views/wktime/_edit_hours.html.erb (0.0ms) Rendered plugins/redmine_wktime/app/views/wktime/_edit_hours.html.erb (0.0ms) Rendered plugins/redmine_wktime/app/views/wktime/_edit_hours.html.erb (0.0ms) Rendered plugins/redmine_wktime/app/views/wktime/_edit_hours.html.erb (0.0ms) Rendered plugins/redmine_wktime/app/views/wktime/_edit_hours.html.erb (0.0ms) Rendered plugins/redmine_wktime/app/views/wktime/_edit_hours.html.erb (0.0ms) Rendered plugins/redmine_wktime/app/views/wktime/_wktime_cf_in_row.erb (0.0ms) Rendered plugins/redmine_wktime/app/views/wktime/_edit_issues2.html.erb (0.0ms) Rendered plugins/redmine_wktime/app/views/wktime/_edit_hours.html.erb (0.0ms) Rendered plugins/redmine_wktime/app/views/wktime/_edit_hours.html.erb (0.0ms) Rendered plugins/redmine_wktime/app/views/wktime/_edit_hours.html.erb (0.0ms) Rendered plugins/redmine_wktime/app/views/wktime/_edit_hours.html.erb (0.0ms) Rendered plugins/redmine_wktime/app/views/wktime/_edit_hours.html.erb (15.6ms) Rendered plugins/redmine_wktime/app/views/wktime/_edit_issues.html.erb (171.9ms) Rendered plugins/redmine_wktime/app/views/wktime/_edit_footer.html.erb (0.0ms) Rendered plugins/redmine_wktime/app/views/wktime/edit.html.erb within layouts/base (203.1ms) Completed 200 OK in 328ms (Views: 234.4ms | ActiveRecord: 15.6ms) Connecting to database specified by database.yml OpenIdAuthentication.store is nil. Using in-memory store. Creating scope :sorted. Overwriting existing method Group.sorted. Creating scope :sorted. Overwriting existing method User.sorted. Started GET "/wktime/index?utf8=%E2%9C%93&getusers_url=%2Fwktime%2Fgetusers&tab=wktime&project_id=2&user_id=0&status=all&period_type=1&period=current_year" for 127.0.0.1 at 2013-07-17 13:29:03 +0800 Processing by WktimeController#index as / Parameters: {"utf8"=>"✓", "getusers_url"=>"/wktime/getusers", "tab"=>"wktime", "project_id"=>"2", "user_id"=>"0", "status"=>"all", "period_type"=>"1", "period"=>"current_year"} Current user: xwj (id=5) DEPRECATION WARNING: Paginator no longer takes a controller instance as the first argument. Remove it from #new arguments. (called from initialize at C:/Sites/redmine-2.3.0/lib/redmine/pagination.rb:28) DEPRECATION WARNING: Paginator#items_per_page will be removed. Use #per_page instead. (called from items_per_page at C:/Sites/redmine-2.3.0/lib/redmine/pagination.rb:94) DEPRECATION WARNING: Paginator#current will be removed. Use .offset instead of .current.offset. (called from current at C:/Sites/redmine-2.3.0/lib/redmine/pagination.rb:99) Rendered plugins/redmine_wktime/app/views/wktime/_tab_content.html.erb (0.0ms) Rendered plugins/redmine_wktime/app/views/wktime/_tab_content.html.erb (0.0ms) Rendered common/_tabs.html.erb (0.0ms) Rendered plugins/redmine_wktime/app/views/wktime/_date_range.html.erb (15.6ms) Rendered plugins/redmine_wktime/app/views/wktime/_list.html.erb (15.6ms) Rendered plugins/redmine_wktime/app/views/wktime/_te_index.html.erb (140.6ms) Rendered plugins/redmine_wktime/app/views/wktime/index.html.erb within layouts/base (406.2ms) Completed 200 OK in 2172ms (Views: 468.8ms | ActiveRecord: 78.1ms) Started GET "/wktime/index?utf8=%E2%9C%93&getusers_url=%2Fwktime%2Fgetusers&tab=wktime&project_id=2&user_id=0&status=all&period_type=1&period=current_year" for 127.0.0.1 at 2013-07-17 13:29:08 +0800 Processing by WktimeController#index as / Parameters: {"utf8"=>"✓", "getusers_url"=>"/wktime/getusers", "tab"=>"wktime", "project_id"=>"2", "user_id"=>"0", "status"=>"all", "period_type"=>"1", "period"=>"current_year"} Current user: xwj (id=5) DEPRECATION WARNING: Paginator no longer takes a controller instance as the first argument. Remove it from #new arguments. (called from initialize at C:/Sites/redmine-2.3.0/lib/redmine/pagination.rb:28) DEPRECATION WARNING: Paginator#items_per_page will be removed. Use #per_page instead. (called from items_per_page at C:/Sites/redmine-2.3.0/lib/redmine/pagination.rb:94) DEPRECATION WARNING: Paginator#current will be removed. Use .offset instead of .current.offset. (called from current at C:/Sites/redmine-2.3.0/lib/redmine/pagination.rb:99) Rendered plugins/redmine_wktime/app/views/wktime/_tab_content.html.erb (0.0ms) Rendered plugins/redmine_wktime/app/views/wktime/_tab_content.html.erb (0.0ms) Rendered common/_tabs.html.erb (0.0ms) Rendered plugins/redmine_wktime/app/views/wktime/_date_range.html.erb (0.0ms) Rendered plugins/redmine_wktime/app/views/wktime/_list.html.erb (15.6ms) Rendered plugins/redmine_wktime/app/views/wktime/_te_index.html.erb (15.6ms) Rendered plugins/redmine_wktime/app/views/wktime/index.html.erb within layouts/base (15.6ms) Completed 200 OK in 47ms (Views: 31.2ms | ActiveRecord: 0.0ms) Started GET "/wktime/edit?project_Id=2&startday=2013-04-21&tab=wktime&user_id=3" for 127.0.0.1 at 2013-07-17 13:29:12 +0800 Processing by WktimeController#edit as HTML Parameters: {"project_Id"=>"2", "startday"=>"2013-04-21", "tab"=>"wktime", "user_id"=>"3"} Current user: xwj (id=5) Rendered plugins/redmine_wktime/app/views/wktime/_wktime_cf_in_row.erb (0.0ms) Rendered plugins/redmine_wktime/app/views/wktime/_edit_issues2.html.erb (15.6ms) Rendered plugins/redmine_wktime/app/views/wktime/_edit_hours.html.erb (0.0ms) Rendered plugins/redmine_wktime/app/views/wktime/_row_template.html.erb (15.6ms) Rendered plugins/redmine_wktime/app/views/wktime/_edit_header.html.erb (15.6ms) Rendered plugins/redmine_wktime/app/views/wktime/_wktime_cf_in_row_header.html.erb (0.0ms) Rendered plugins/redmine_wktime/app/views/wktime/_issue_header.html.erb (15.6ms) Rendered plugins/redmine_wktime/app/views/wktime/_edit_hours.html.erb (0.0ms) Rendered plugins/redmine_wktime/app/views/wktime/_wktime_cf_in_row.erb (0.0ms) Rendered plugins/redmine_wktime/app/views/wktime/_edit_issues2.html.erb (0.0ms) Rendered plugins/redmine_wktime/app/views/wktime/_edit_hours.html.erb (0.0ms) Rendered plugins/redmine_wktime/app/views/wktime/_edit_hours.html.erb (0.0ms) Rendered plugins/redmine_wktime/app/views/wktime/_edit_hours.html.erb (0.0ms) Rendered plugins/redmine_wktime/app/views/wktime/_edit_hours.html.erb (0.0ms) Rendered plugins/redmine_wktime/app/views/wktime/_edit_hours.html.erb (0.0ms) Rendered plugins/redmine_wktime/app/views/wktime/_edit_hours.html.erb (0.0ms) Rendered plugins/redmine_wktime/app/views/wktime/_edit_hours.html.erb (0.0ms) Rendered plugins/redmine_wktime/app/views/wktime/_wktime_cf_in_row.erb (0.0ms) Rendered plugins/redmine_wktime/app/views/wktime/_edit_issues2.html.erb (0.0ms) Rendered plugins/redmine_wktime/app/views/wktime/_edit_hours.html.erb (0.0ms) Rendered plugins/redmine_wktime/app/views/wktime/_edit_hours.html.erb (0.0ms) Rendered plugins/redmine_wktime/app/views/wktime/_edit_hours.html.erb (0.0ms) Rendered plugins/redmine_wktime/app/views/wktime/_edit_hours.html.erb (0.0ms) Rendered plugins/redmine_wktime/app/views/wktime/_edit_hours.html.erb (0.0ms) Rendered plugins/redmine_wktime/app/views/wktime/_edit_issues.html.erb (62.5ms) Rendered plugins/redmine_wktime/app/views/wktime/_edit_footer.html.erb (0.0ms) Rendered plugins/redmine_wktime/app/views/wktime/edit.html.erb within layouts/base (109.4ms) Completed 200 OK in 281ms (Views: 187.5ms | ActiveRecord: 31.2ms) Connecting to database specified by database.yml OpenIdAuthentication.store is nil. Using in-memory store. Creating scope :sorted. Overwriting existing method Group.sorted. Creating scope :sorted. Overwriting existing method User.sorted. Started GET "/wktime/index?utf8=%E2%9C%93&getusers_url=%2Fwktime%2Fgetusers&tab=wktime&project_id=2&user_id=0&status=all&period_type=1&period=current_year" for 127.0.0.1 at 2013-07-17 13:32:35 +0800 Processing by WktimeController#index as / Parameters: {"utf8"=>"✓", "getusers_url"=>"/wktime/getusers", "tab"=>"wktime", "project_id"=>"2", "user_id"=>"0", "status"=>"all", "period_type"=>"1", "period"=>"current_year"} Current user: xwj (id=5) DEPRECATION WARNING: Paginator no longer takes a controller instance as the first argument. Remove it from #new arguments. (called from initialize at C:/Sites/redmine-2.3.0/lib/redmine/pagination.rb:28) DEPRECATION WARNING: Paginator#items_per_page will be removed. Use #per_page instead. (called from items_per_page at C:/Sites/redmine-2.3.0/lib/redmine/pagination.rb:94) DEPRECATION WARNING: Paginator#current will be removed. Use .offset instead of .current.offset. (called from current at C:/Sites/redmine-2.3.0/lib/redmine/pagination.rb:99) Rendered plugins/redmine_wktime/app/views/wktime/_tab_content.html.erb (0.0ms) Rendered plugins/redmine_wktime/app/views/wktime/_tab_content.html.erb (0.0ms) Rendered common/_tabs.html.erb (15.6ms) Rendered plugins/redmine_wktime/app/views/wktime/_date_range.html.erb (0.0ms) Rendered plugins/redmine_wktime/app/views/wktime/_list.html.erb (31.2ms) Rendered plugins/redmine_wktime/app/views/wktime/_te_index.html.erb (109.4ms) Rendered plugins/redmine_wktime/app/views/wktime/index.html.erb within layouts/base (390.6ms) Completed 200 OK in 2203ms (Views: 437.5ms | ActiveRecord: 78.1ms) Started GET "/wktime/index?utf8=%E2%9C%93&getusers_url=%2Fwktime%2Fgetusers&tab=wktime&project_id=2&user_id=0&status=all&period_type=1&period=current_year" for 127.0.0.1 at 2013-07-17 13:32:39 +0800 Processing by WktimeController#index as / Parameters: {"utf8"=>"✓", "getusers_url"=>"/wktime/getusers", "tab"=>"wktime", "project_id"=>"2", "user_id"=>"0", "status"=>"all", "period_type"=>"1", "period"=>"current_year"} Current user: xwj (id=5) DEPRECATION WARNING: Paginator no longer takes a controller instance as the first argument. Remove it from #new arguments. (called from initialize at C:/Sites/redmine-2.3.0/lib/redmine/pagination.rb:28) DEPRECATION WARNING: Paginator#items_per_page will be removed. Use #per_page instead. (called from items_per_page at C:/Sites/redmine-2.3.0/lib/redmine/pagination.rb:94) DEPRECATION WARNING: Paginator#current will be removed. Use .offset instead of .current.offset. (called from current at C:/Sites/redmine-2.3.0/lib/redmine/pagination.rb:99) Rendered plugins/redmine_wktime/app/views/wktime/_tab_content.html.erb (0.0ms) Rendered plugins/redmine_wktime/app/views/wktime/_tab_content.html.erb (0.0ms) Rendered common/_tabs.html.erb (0.0ms) Rendered plugins/redmine_wktime/app/views/wktime/_date_range.html.erb (0.0ms) Rendered plugins/redmine_wktime/app/views/wktime/_list.html.erb (15.6ms) Rendered plugins/redmine_wktime/app/views/wktime/_te_index.html.erb (15.6ms) Rendered plugins/redmine_wktime/app/views/wktime/index.html.erb within layouts/base (15.6ms) Completed 200 OK in 47ms (Views: 31.2ms | ActiveRecord: 0.0ms) Started GET "/wktime/edit?project_Id=2&startday=2013-04-21&tab=wktime&user_id=3" for 127.0.0.1 at 2013-07-17 13:32:42 +0800 Processing by WktimeController#edit as HTML Parameters: {"project_Id"=>"2", "startday"=>"2013-04-21", "tab"=>"wktime", "user_id"=>"3"} Current user: xwj (id=5) Rendered plugins/redmine_wktime/app/views/wktime/_wktime_cf_in_row.erb (0.0ms) Rendered plugins/redmine_wktime/app/views/wktime/_edit_issues2.html.erb (0.0ms) Rendered plugins/redmine_wktime/app/views/wktime/_edit_hours.html.erb (0.0ms) Rendered plugins/redmine_wktime/app/views/wktime/_row_template.html.erb (15.6ms) Rendered plugins/redmine_wktime/app/views/wktime/_edit_header.html.erb (15.6ms) Rendered plugins/redmine_wktime/app/views/wktime/_wktime_cf_in_row_header.html.erb (0.0ms) Rendered plugins/redmine_wktime/app/views/wktime/_issue_header.html.erb (15.6ms) Rendered plugins/redmine_wktime/app/views/wktime/_edit_hours.html.erb (0.0ms) Rendered plugins/redmine_wktime/app/views/wktime/_wktime_cf_in_row.erb (0.0ms) Rendered plugins/redmine_wktime/app/views/wktime/_edit_issues2.html.erb (0.0ms) Rendered plugins/redmine_wktime/app/views/wktime/_edit_hours.html.erb (0.0ms) Rendered plugins/redmine_wktime/app/views/wktime/_edit_hours.html.erb (0.0ms) Rendered plugins/redmine_wktime/app/views/wktime/_edit_hours.html.erb (0.0ms) Rendered plugins/redmine_wktime/app/views/wktime/_edit_hours.html.erb (0.0ms) Rendered plugins/redmine_wktime/app/views/wktime/_edit_hours.html.erb (0.0ms) Rendered plugins/redmine_wktime/app/views/wktime/_edit_hours.html.erb (0.0ms) Rendered plugins/redmine_wktime/app/views/wktime/_edit_hours.html.erb (0.0ms) Rendered plugins/redmine_wktime/app/views/wktime/_wktime_cf_in_row.erb (0.0ms) Rendered plugins/redmine_wktime/app/views/wktime/_edit_issues2.html.erb (0.0ms) Rendered plugins/redmine_wktime/app/views/wktime/_edit_hours.html.erb (0.0ms) Rendered plugins/redmine_wktime/app/views/wktime/_edit_hours.html.erb (0.0ms) Rendered plugins/redmine_wktime/app/views/wktime/_edit_hours.html.erb (0.0ms) Rendered plugins/redmine_wktime/app/views/wktime/_edit_hours.html.erb (0.0ms) Rendered plugins/redmine_wktime/app/views/wktime/_edit_hours.html.erb (0.0ms) Rendered plugins/redmine_wktime/app/views/wktime/_edit_issues.html.erb (109.4ms) Rendered plugins/redmine_wktime/app/views/wktime/_edit_footer.html.erb (0.0ms) Rendered plugins/redmine_wktime/app/views/wktime/edit.html.erb within layouts/base (156.2ms) Completed 200 OK in 281ms (Views: 171.9ms | ActiveRecord: 62.5ms)
#34 楼 @w_jie guides 特指 http://guides.ruby-china.org/ 你的服务是 production 启动的吧 sql 是不显示的...
#39 楼 @w_jie 笑了 一个眼睛大 一个眼睛小 你先看看 http://guides.ruby-china.org/active_record_querying.html 然后晚一点再帮你解决 rails s 启动就是 development 模式~
#40 楼 @zj0713001 你说的启动 development 模式是用这个命令?我这结果是不是失败?是命令不对么?
C:\Sites\redmine-2.3.0>rails s
=> Booting WEBrick
=> Rails 3.2.13 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
Exiting
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/mysql2-0.3.11-x86-mingw32/l
ib/mysql2/client.rb:44:in connect': Access denied for user 'root'@'localhost' (
using password: NO) (Mysql2::Error)
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/mysql2-0.3.11-
x86-mingw32/lib/mysql2/client.rb:44:in
initialize'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-3
.2.13/lib/active_record/connection_adapters/mysql2_adapter.rb:16:in new'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-3
.2.13/lib/active_record/connection_adapters/mysql2_adapter.rb:16:in
mysql2_conn
ection'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-3
.2.13/lib/active_record/connection_adapters/abstract/connection_pool.rb:315:in
new_connection'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-3
.2.13/lib/active_record/connection_adapters/abstract/connection_pool.rb:325:in
checkout_new_connection'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-3
.2.13/lib/active_record/connection_adapters/abstract/connection_pool.rb:247:in
block (2 levels) in checkout'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-3
.2.13/lib/active_record/connection_adapters/abstract/connection_pool.rb:242:in
loop'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-3
.2.13/lib/active_record/connection_adapters/abstract/connection_pool.rb:242:in
block in checkout'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/monitor.rb:211:in
mon_s
ynchronize'