I solved this in the end. It turned out I had customised the
initialize method of CustomBlock. SoI added def initialize(args=nil,
&block) and all worked swimmingly
On Aug 12, 11:32 am, Iain Adams <iain.adams.1...@googlemail.com>
wrote:> Hello,
>
> I am stuck in a little hole that I cannot seem to fix. No doubt
it''s
> something stupid. Basically I am trying to clone a "block" and
give it
> a new title and save it again.
>
> My controller code looks like this:
>
> def copy
> begin
>
> @block = CustomBlock.find params[:id]
> @block_cp = @block.clone
> @block_cp.title = "Copy of #...@block.title}"
> @block_cp.save
>
> render :update do |page|
> page.replace_html ''unused'', :partial
=> ''unused''
> end
>
> rescue ActiveRecord::RecordNotFound
> render_404
> end
> end
>
> I get the error
>
> wrong number of arguments (0 for 1) - pointing to line 107 which is
> @block_cp = @block.clone, as shown below -
>
> /usr/lib/ruby/gems/1.8/gems/activerecord-1.15.1/lib/active_record/
> base.rb:1563:in `initialize''
> /usr/lib/ruby/gems/1.8/gems/activerecord-1.15.1/lib/active_record/
> base.rb:1563:in `new''
> /usr/lib/ruby/gems/1.8/gems/activerecord-1.15.1/lib/active_record/
> base.rb:1563:in `clone''
> #{RAILS_ROOT}/app/controllers/block_admin_controller.rb:107:in
`copy''
> /usr/bin/mongrel_rails:16:in `load''
> /usr/bin/mongrel_rails:16
>
> I am using Rails 1.2.3 anyone any ideas???
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Core" group.
To post to this group, send email to rubyonrails-core@googlegroups.com
To unsubscribe from this group, send email to
rubyonrails-core+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/rubyonrails-core?hl=en
-~----------~----~----~----~------~----~------~--~---