Note that there are some explanatory texts on larger screens.

plurals
  1. POGetting weird save error when trying to clone existing attributes to new entry in my db
    primarykey
    data
    text
    <p>controller (tce_params_controller)</p> <pre><code>def clone tce_params = TceParamSet.find(params[:id]) puts "This is tce_params" puts tce_params cloned_tce_params = tce_params.clone puts "This is cloned_tce_params" puts cloned_tce_params if @saved == true flash[:notice] = 'Item was successfully cloned.' redirect_to edit_tce_param_set_path(@cloned_tce_params) else flash[:notice] = 'ERROR: Item can\'t be clone' puts cloned_tce_params.errors redirect_to system_data_path end end </code></pre> <p>Model(TceParamSet)</p> <pre><code>def clone cloned_tce_params = TceParamSet.new(self.attributes) puts "this is attributes in model" puts cloned_tce_params.attributes cloned_tce_params.id = nil if cloned_tce_params.save cloned_tce_params = cloned_tce_params.name + "(cloned)" @saved = true else @saved = false end return cloned_tce_params end </code></pre> <p>views</p> <pre><code>=link_to "Clone", clone_test_group_path(test_group), :method =&gt; :clone, :class =&gt; :tce_param_sets </code></pre> <p>Route</p> <pre><code>map.connect '/tce_param_sets/:id/clone', :controller =&gt; "tce_param_sets", :action =&gt; "clone" </code></pre> <p>When I run this, I get an error saying"</p> <p>NoMethodError in Tce param setsController#clone</p> <p>undefined method `save' for #(Table doesn't exist)</p> <p>/usr/local/rvm/gems/ruby-1.8.7-p357@rails238/gems/rails-2.3.8/lib/commands/server.rb:111 /usr/local/rvm/rubies/ruby-1.8.7-p357/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in <code>gem_original_require' /usr/local/rvm/rubies/ruby-1.8.7-p357/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in</code>require' script/server:3</p> <p>Request</p> <p>Parameters:</p> <p>{"id"=>"3"}</p> <p>Show session dump</p> <hr> <p>Response</p> <p>Headers:</p> <p>{"Content-Type"=>"", "Cache-Control"=>"no-cache"}</p> <p>using this code I get </p> <p>Processing TceParamSetsController#clone (for 127.0.0.1 at 2012-03-12 09:36:37) [GET] Parameters: {"id"=>"2"} TceParamSet Load (1.5ms) SELECT * FROM "tce_param_sets" WHERE ("tce_param_sets"."id" = 2) WARNING: Can't mass-assign these protected attributes: id SQL (0.3ms) BEGIN TceParamSet Load (0.8ms) SELECT "tce_param_sets".id FROM "tce_param_sets" WHERE ("tce_param_sets"."name" = 'Perf: 14520 - Fairshare TM 4.00 (latest) - PTS 6.00 (latest TM-4.00 branch) - NA Wireline') LIMIT 1 SQL (0.4ms) ROLLBACK</p> <p>Why is this happening? I am not giving id any value yet it is saying I am trying to assign ids...</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload