Hi
a) I have 2 tables, namely workplans and timesheets.
b) What I am trying to do is to add a custom link to AS List ... OK
c) Then, when I click this link eg ''transfer2timesheet'', a new
record
will then be created in the timesheets table and populated with the
values from the workplan table
d) I added a transfer2timesheet method after the local config block
in workplans controller as follows :-
class WorkplansController < ApplicationController
active_scaffold :workplan do |config|
config.columns
=[:calen_date,:staff,:customer,:category,:work_plan,:no_of_hrs, :where_work]
config.action_links.add ''transfer2timesheet'', :label
=>''Transfer'', :type => :record, :page => false
end
def transfer2timesheet
newtimesheet=Timesheet.new
newtimesheet=User.current_user.login
sourcetable=Workplan.find(Param[:id]) # this where the 500
error is triggered
newtimesheet.where_work=sourcetable.where_work
newtimesheet.save
end
end
Result : 500 error
Processing WorkplansController#transfer2timesheet (for 127.0.0.1 at
2007-10-21 22:58:54) [GET]
Session ID: 072faf9dce18c4052cdc6a3386ec724c
Parameters: {"adapter"=>"_list_inline_adapter",
"_method"=>"get",
"action"=>"transfer2timesheet",
"id"=>"6686",
"controller"=>"workplans"}
NameError (uninitialized constant WorkplansController::Param):
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.4/
lib/active_support/dependencies.rb:477:in `const_missing''
D:/Aptana_Workspace/crm4web/app/controllers/
workplans_controller.rb:83:in `transfer2timesheet''
e) I have also tried
def transfer2timesheet
newtimesheet=Timesheet.new
newtimesheet=User.current_user.login
newtimesheet.where_work=Workplan.where_work # this where the 500
error is triggered
newtimesheet.save
end
end
Result : 500 error
Processing WorkplansController#transfer2timesheet (for 127.0.0.1 at
2007-10-21 23:23:56) [GET]
Session ID: 072faf9dce18c4052cdc6a3386ec724c
Parameters: {"adapter"=>"_list_inline_adapter",
"_method"=>"get",
"action"=>"transfer2timesheet",
"id"=>"6686",
"controller"=>"workplans"}
NoMethodError (undefined method `where_work'' for Workplan:Class):
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.5/
lib/active_record/base.rb:1238:in `method_missing''
D:/Aptana_Workspace/crm4web/app/controllers/
workplans_controller.rb:84:in `transfer2timesheet''
Any assistance to resolve the error in (d) and (e) is greatly
appreciated.
TIA.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---