Project

General

Profile

datetime_select funktioniert nicht wie sonst wo

Added by Christian Janz over 14 years ago

Ich hab ein Problem, weil ich glaube ich die HelperFunktion datetime_select nicht korrekt eingesetzt bekomme.
Da ich gerade an meiner Diplomarbeit sitze benötige ich da relativ dringend Hilfe

Folgendes:

Ich schreibe ein Plugin alle Dateien models views etc liegen in vendor/plugins/red...pluginname

In einem View möchte ich nun ein datetime value mittels datetime_select anzeigen lassen.
auf meiner website ist der grobe Prototyp der Seite zu sehen:
http://pansen.no-ip.com/projekte/DiplArbeit/Prototyp/timesheet_erfassung_manuell.html

Anstelle der beiden oberen ausgegrauten Kästechen sollen diese datetime_selectoren hin.
Der Aufruf des ganzen gelingt mir nur nicht. (Aso QCode kommt unten samt der Zusammenhänge)
Cool ist auch das ein anderes Projekt mit dem selben Rails 2.1.2 (Redmine halt) mir aus den
Scaffold befehlen heraus etwas generiert das genau so aussieht wie mein Code und der lüppt dort
und in redmine halt nicht.....

Hab Ihr Ideen. Besten Dank!

Gruß Christian

meine klassen hierarchie ist relativ flach

CostCenter 1-* Apportionment *-1 WorkingTime *-1 User
Alle bis auf User sind eigene Klassen.

CostCenter
-------------
+name:string
+description:text
+shortcut:string

Apportionment
--------------
+apportionment_begin:DateTime
+apportionment_duration:BigInt
+cost_center_id:Integer
+working_time_id:Integer

WorkingTime
------------
+working_time_begin:DateTime
+working_time_end:DateTime
+user_id:Integer

ausschnitt aus dem Controller

working_time_controller.rb

...
def edit_manual
@working_time = WorkingTime.find(:first, :conditions => {:user_id => User.current.id, :working_time_end => nil}, :order => "working_time_begin asc")
if @working_time.nil?
@working_time = WorkingTime.find(:first, :conditions => {:user_id => User.current.id}, :order => "working_time_end desc")
end
CostCenter.find( :all, :order => 'name asc').each do |cost_center|
if !@working_time.apportionments.any? {|a| a.cost_center == cost_center}
@working_time.apportionments.build({:cost_center => cost_center})
end
end
end #ich bekomme auf jedenfall eine @workingTime ausser ich werde direkt an der DB sabotiert.
...

und hier die dazu passende *.erb
edit_manual.html.erb
@...
<% if is_access_granted(User.current) >
<div id="timesheet-menu">
<ul>
<li><a href="/workingtimes/new" class="overview">Erfassung</a></li>
<li><a href="/workingtimes/edit_manual" class="overview selected">Erfassung Manuell</a></li>
<li><a href="/projects/tsp/issues" class="issues">Woche</a></li>
<li><a href="/projects/tsp/issues/new" accesskey="7" class="new-issue">Monat</a></li>
<
if is_manager(User.current) || User.current.admin >
<li><a href="/projects/tsp/news" class="news">Mitarbeiterübersicht</a></li>
<li><a href="/projects/tsp/documents" class="documents">Kostenstellenübersicht</a></li>
<li><a href="/cost_centers/index" class="files">Kostenstellenverwaltung</a></li>
<
end %>
</ul>
</div>

<div id="inner_content">

&lt;h2&gt;Workingtimes#edit_manual Erfassung&lt;/h2&gt;
<% form_for(:working_time, @working_time, :url => {:action => 'update'}) do |f| %>
&lt;div class="box"&gt;
&lt;h3 class="icon22 icon22-tracker"&gt;Arbeitszeit&lt;/h3&gt;
&lt;table&gt;
&lt;tr&gt;
&lt;td&gt;
Arbeitszeitbegin
&lt;/td&gt;
&lt;td&gt;
Arbeitszeitende
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
<%= f.datetime_select :working_time_begin > &lt;!-- Hier funzt nichts laut api aber solls so gehen --&gt;
&lt;/td&gt;
&lt;td&gt;
<
= f.datetime_select :working_time_end %> &lt;!-- Hier funzt nichts laut api aber solls so gehen --&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;div class="box"&gt;
&lt;h3 class="icon22 icon22-tracker"&gt;Kostenstellen&lt;/h3&gt;
&lt;p&gt;
&lt;span&gt;
Wenn eine Kostenstelle Ihrer Meinung nach falsch bebucht wurde korrigieren Sie den Wert bitte.&lt;br /&gt;
Verwenden Sie bitte das vorgegebene Eingabemuster.
&lt;/span&gt;
&lt;/p&gt;
&lt;table&gt;
&lt;tr&gt;
&lt;th&gt;Kostenstelle&lt;/th&gt;
&lt;th&gt;Eingabe&lt;/th&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Kostenstelle&lt;/td&gt;
&lt;td&gt;Eingabe&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;/div&gt;
<% end >
&lt;/div&gt;
<
content_for :header_tags do >
<
= stylesheet_link_tag 'timesheets', :plugin => 'redmine_time_sheet' >
<
end >
<
end %>
....@

EOF die Vorschau sieht grottig aus.. mal sehen was das hier bringt.


Replies (1)

RE: datetime_select funktioniert nicht wie sonst wo - Added by Christian Janz over 14 years ago

ASO Ich hab übrigens folgende Fehlermeldung

ArgumentError in Workingtimes#edit_manual

Showing workingtimes/edit_manual.html.erb where line #34 raised:

wrong number of arguments (3 for 2)

Extracted source (around line #34):

31: </tr>
32: <tr>
33: <td>
34: <%= f.datetime_select :working_time_begin %>
35: </td>
36: <td>
37: </td>

RAILS_ROOT: /home/pansen/DEV/redmine-0.8.4
Application Trace | Framework Trace | Full Trace

vendor/rails/actionpack/lib/action_view/helpers/date_helper.rb:651:in `select_day'
vendor/rails/actionpack/lib/action_view/helpers/date_helper.rb:651:in `send'
vendor/rails/actionpack/lib/action_view/helpers/date_helper.rb:651:in `date_or_time_select'
vendor/rails/actionpack/lib/action_view/helpers/date_helper.rb:646:in `each'
vendor/rails/actionpack/lib/action_view/helpers/date_helper.rb:646:in `date_or_time_select'
vendor/rails/actionpack/lib/action_view/helpers/date_helper.rb:610:in `to_datetime_select_tag_without_error_wrapping'
vendor/rails/actionpack/lib/action_view/helpers/active_record_helper.rb:248:in `to_datetime_select_tag'
vendor/rails/actionpack/lib/action_view/helpers/date_helper.rb:217:in `datetime_select'
vendor/rails/actionpack/lib/action_view/helpers/date_helper.rb:707:in `datetime_select'
vendor/plugins/redmine_time_sheet/app/views/workingtimes/edit_manual.html.erb:34:in `_run_erb_47vendor47plugins47redmine_time_sheet47app47views47workingtimes47edit_manual46html46erb'
vendor/rails/actionpack/lib/action_view/helpers/form_helper.rb:317:in `fields_for'
vendor/rails/actionpack/lib/action_view/helpers/form_helper.rb:253:in `form_for'
vendor/plugins/redmine_time_sheet/app/views/workingtimes/edit_manual.html.erb:19:in `_run_erb_47vendor47plugins47redmine_time_sheet47app47views47workingtimes47edit_manual46html46erb'
vendor/rails/actionpack/lib/action_view/base.rb:342:in `send'
vendor/rails/actionpack/lib/action_view/base.rb:342:in `execute'
vendor/rails/actionpack/lib/action_view/template_handlers/compilable.rb:29:in `send'
vendor/rails/actionpack/lib/action_view/template_handlers/compilable.rb:29:in `render'
vendor/rails/actionpack/lib/action_view/template.rb:35:in `render'
vendor/rails/actionpack/lib/action_view/template.rb:22:in `render_template'
vendor/rails/actionpack/lib/action_view/base.rb:248:in `render_file'
vendor/rails/actionpack/lib/action_controller/base.rb:1112:in `render_for_file'
vendor/rails/actionpack/lib/action_controller/base.rb:845:in `render_with_no_layout'
vendor/rails/actionpack/lib/action_controller/layout.rb:251:in `render_without_benchmark'
vendor/rails/actionpack/lib/action_controller/benchmarking.rb:51:in `render'
vendor/rails/activesupport/lib/active_support/core_ext/benchmark.rb:8:in `realtime'
vendor/rails/actionpack/lib/action_controller/benchmarking.rb:51:in `render'
vendor/rails/actionpack/lib/action_controller/base.rb:1161:in `default_render'
vendor/rails/actionpack/lib/action_controller/base.rb:1167:in `perform_action_without_filters'
vendor/rails/actionpack/lib/action_controller/filters.rb:579:in `call_filters'
vendor/rails/actionpack/lib/action_controller/filters.rb:572:in `perform_action_without_benchmark'
vendor/rails/actionpack/lib/action_controller/benchmarking.rb:68:in `perform_action_without_rescue'
/usr/lib/ruby/1.8/benchmark.rb:293:in `measure'
vendor/rails/actionpack/lib/action_controller/benchmarking.rb:68:in `perform_action_without_rescue'
vendor/rails/actionpack/lib/action_controller/rescue.rb:201:in `perform_action_without_caching'
vendor/rails/actionpack/lib/action_controller/caching/sql_cache.rb:13:in `perform_action'
vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb:33:in `cache'
vendor/rails/activerecord/lib/active_record/query_cache.rb:8:in `cache'
vendor/rails/actionpack/lib/action_controller/caching/sql_cache.rb:12:in `perform_action'
vendor/rails/actionpack/lib/action_controller/base.rb:529:in `send'
vendor/rails/actionpack/lib/action_controller/base.rb:529:in `process_without_filters'
vendor/rails/actionpack/lib/action_controller/filters.rb:568:in `process_without_session_management_support'
vendor/rails/actionpack/lib/action_controller/session_management.rb:130:in `process'
vendor/rails/actionpack/lib/action_controller/base.rb:389:in `process'
vendor/rails/actionpack/lib/action_controller/dispatcher.rb:149:in `handle_request'
vendor/rails/actionpack/lib/action_controller/dispatcher.rb:107:in `dispatch'
vendor/rails/actionpack/lib/action_controller/dispatcher.rb:104:in `synchronize'
vendor/rails/actionpack/lib/action_controller/dispatcher.rb:104:in `dispatch'
vendor/rails/actionpack/lib/action_controller/dispatcher.rb:120:in `dispatch_cgi'
vendor/rails/actionpack/lib/action_controller/dispatcher.rb:35:in `dispatch'
vendor/rails/railties/lib/webrick_server.rb:112:in `handle_dispatch'
vendor/rails/railties/lib/webrick_server.rb:78:in `service'
/usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
/usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
/usr/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
/usr/lib/ruby/1.8/webrick/server.rb:162:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
/usr/lib/ruby/1.8/webrick/server.rb:95:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:92:in `each'
/usr/lib/ruby/1.8/webrick/server.rb:92:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:23:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:82:in `start'
vendor/rails/railties/lib/webrick_server.rb:62:in `dispatch'
vendor/rails/railties/lib/commands/servers/webrick.rb:66
/usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
/usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `require'
vendor/rails/activesupport/lib/active_support/dependencies.rb:510:in `require'
vendor/rails/activesupport/lib/active_support/dependencies.rb:355:in `new_constants_in'
vendor/rails/activesupport/lib/active_support/dependencies.rb:510:in `require'
vendor/rails/railties/lib/commands/server.rb:39
/usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
/usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `require'
script/server:3

vendor/rails/actionpack/lib/action_view/helpers/date_helper.rb:651:in `select_day'
vendor/rails/actionpack/lib/action_view/helpers/date_helper.rb:651:in `send'
vendor/rails/actionpack/lib/action_view/helpers/date_helper.rb:651:in `date_or_time_select'
vendor/rails/actionpack/lib/action_view/helpers/date_helper.rb:646:in `each'
vendor/rails/actionpack/lib/action_view/helpers/date_helper.rb:646:in `date_or_time_select'
vendor/rails/actionpack/lib/action_view/helpers/date_helper.rb:610:in `to_datetime_select_tag_without_error_wrapping'
vendor/rails/actionpack/lib/action_view/helpers/active_record_helper.rb:248:in `to_datetime_select_tag'
vendor/rails/actionpack/lib/action_view/helpers/date_helper.rb:217:in `datetime_select'
vendor/rails/actionpack/lib/action_view/helpers/date_helper.rb:707:in `datetime_select'
vendor/plugins/redmine_time_sheet/app/views/workingtimes/edit_manual.html.erb:34:in `_run_erb_47vendor47plugins47redmine_time_sheet47app47views47workingtimes47edit_manual46html46erb'
vendor/rails/actionpack/lib/action_view/helpers/form_helper.rb:317:in `fields_for'
vendor/rails/actionpack/lib/action_view/helpers/form_helper.rb:253:in `form_for'
vendor/plugins/redmine_time_sheet/app/views/workingtimes/edit_manual.html.erb:19:in `_run_erb_47vendor47plugins47redmine_time_sheet47app47views47workingtimes47edit_manual46html46erb'
vendor/rails/actionpack/lib/action_view/base.rb:342:in `send'
vendor/rails/actionpack/lib/action_view/base.rb:342:in `execute'
vendor/rails/actionpack/lib/action_view/template_handlers/compilable.rb:29:in `send'
vendor/rails/actionpack/lib/action_view/template_handlers/compilable.rb:29:in `render'
vendor/rails/actionpack/lib/action_view/template.rb:35:in `render'
vendor/rails/actionpack/lib/action_view/template.rb:22:in `render_template'
vendor/rails/actionpack/lib/action_view/base.rb:248:in `render_file'
vendor/rails/actionpack/lib/action_controller/base.rb:1112:in `render_for_file'
vendor/rails/actionpack/lib/action_controller/base.rb:845:in `render_with_no_layout'
vendor/rails/actionpack/lib/action_controller/layout.rb:251:in `render_without_benchmark'
vendor/rails/actionpack/lib/action_controller/benchmarking.rb:51:in `render'
vendor/rails/activesupport/lib/active_support/core_ext/benchmark.rb:8:in `realtime'
vendor/rails/actionpack/lib/action_controller/benchmarking.rb:51:in `render'
vendor/rails/actionpack/lib/action_controller/base.rb:1161:in `default_render'
vendor/rails/actionpack/lib/action_controller/base.rb:1167:in `perform_action_without_filters'
vendor/rails/actionpack/lib/action_controller/filters.rb:579:in `call_filters'
vendor/rails/actionpack/lib/action_controller/filters.rb:572:in `perform_action_without_benchmark'
vendor/rails/actionpack/lib/action_controller/benchmarking.rb:68:in `perform_action_without_rescue'
/usr/lib/ruby/1.8/benchmark.rb:293:in `measure'
vendor/rails/actionpack/lib/action_controller/benchmarking.rb:68:in `perform_action_without_rescue'
vendor/rails/actionpack/lib/action_controller/rescue.rb:201:in `perform_action_without_caching'
vendor/rails/actionpack/lib/action_controller/caching/sql_cache.rb:13:in `perform_action'
vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb:33:in `cache'
vendor/rails/activerecord/lib/active_record/query_cache.rb:8:in `cache'
vendor/rails/actionpack/lib/action_controller/caching/sql_cache.rb:12:in `perform_action'
vendor/rails/actionpack/lib/action_controller/base.rb:529:in `send'
vendor/rails/actionpack/lib/action_controller/base.rb:529:in `process_without_filters'
vendor/rails/actionpack/lib/action_controller/filters.rb:568:in `process_without_session_management_support'
vendor/rails/actionpack/lib/action_controller/session_management.rb:130:in `process'
vendor/rails/actionpack/lib/action_controller/base.rb:389:in `process'
vendor/rails/actionpack/lib/action_controller/dispatcher.rb:149:in `handle_request'
vendor/rails/actionpack/lib/action_controller/dispatcher.rb:107:in `dispatch'
vendor/rails/actionpack/lib/action_controller/dispatcher.rb:104:in `synchronize'
vendor/rails/actionpack/lib/action_controller/dispatcher.rb:104:in `dispatch'
vendor/rails/actionpack/lib/action_controller/dispatcher.rb:120:in `dispatch_cgi'
vendor/rails/actionpack/lib/action_controller/dispatcher.rb:35:in `dispatch'
vendor/rails/railties/lib/webrick_server.rb:112:in `handle_dispatch'
vendor/rails/railties/lib/webrick_server.rb:78:in `service'
/usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
/usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
/usr/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
/usr/lib/ruby/1.8/webrick/server.rb:162:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
/usr/lib/ruby/1.8/webrick/server.rb:95:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:92:in `each'
/usr/lib/ruby/1.8/webrick/server.rb:92:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:23:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:82:in `start'
vendor/rails/railties/lib/webrick_server.rb:62:in `dispatch'
vendor/rails/railties/lib/commands/servers/webrick.rb:66
/usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
/usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `require'
vendor/rails/activesupport/lib/active_support/dependencies.rb:510:in `require'
vendor/rails/activesupport/lib/active_support/dependencies.rb:355:in `new_constants_in'
vendor/rails/activesupport/lib/active_support/dependencies.rb:510:in `require'
vendor/rails/railties/lib/commands/server.rb:39
/usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
/usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `require'
script/server:3

Request

Parameters:

None

Show session dump

---
:user_id: 1
flash: !map:ActionController::Flash::FlashHash
:notice: Die heutige Arbeitszeit ist nur noch manuell bearbeitbar?

Response

Headers:

{"cookie"=>[],
"Cache-Control"=>"no-cache"}

    (1-1/1)