Ruby On Rails: Using parameters from the new controller function in the create controller function -
Text after "
I am passing in: number as a parameter and then in the code in the controller variable @test_suite_num> before_filter .
In the function in my I do this for controller code: new Create Edit: I have just started using ROR, so my style really Is dirty. Although my problem is still standing, my problem is that in my form, I am using @Tests, which I started with the parameter passed. I can see the form properly, but when I submit, I get: Parameter: {"UTF8" = & gt; "One ????" "Authenticity_token" = & gt; "/ VbOcFozTEAvoa03OUBfyxJbJ9AQp8m8yA04LkxlRE8 =", "test_suite_run" => {"Test_runs_attributes" = & gt; {"0" = & gt; {"Test_id" = & gt; "1", "machine_id" => Looking through this, it's just all my In the form there is text_input areas. You're really doing something weird Rather than assigning Instead, just use If this does not work, then new controller, I use the variable @test_suite_num to filter a table named
test to count the entries whose ID matches To get @test_suite_num I use this count to generate the appropriate number of child resources;
test_run .
create , but for some reason I get a zero error. I use these variables in forms that
@test_suite_num depend on. I am assuming that after making any time, no parameter is taken, the variable is never started. ? How can I use @test_suite_num in
function
before_filter: get_number ,: only => [: New: create] get_number @test_suite_num = params [: number] end
def new @test_suite_run = TestSuiteRun.new @tests = Test.find (: all ,: position = & gt; {test_suite_id = & gt; @test_suite_num}) test cases.times.times test_run = @ end end test_suite_run.test_runs.build
DEF = TestSuiteRun.new @test_suite_run create (parameter [: test_suite_run]) @tests = Test.find (: All ,: position => {: test_suite_id = Gt; @test_suite_num}) @ test.count.times test_run = @ test_suite_run.test_runs.build (parameter [: test_suite_run]) end if @ test_suite_run.save flash [: success] = "Run Added successfully" redirect_t O test_suite_runs_path (@test_suite_run) and submit 'New End End
Showing / Users / vsp / Documents / rails_projects / web_db / app / views / test_suite_runs / _form.html.erb where Row # 13 has been raised: The id has been called for zero, which will be 4 by mistake - if you want the id of zero in fact, use the object_id extracted source (approximately # 13 line): 10: 11: & lt;% = f.fields_for: test_runs do | Builder | & Gt%; 12: 13: Test <% = @tests [@i] .id% & gt; & Lt; Br> & Lt; Br> 14: 15: & lt;% = Render "Partial" ,: f => Builder% & gt; 16: & lt; Hour & gt; Obviously this means that the parameter is not getting on the controller [number] is something wrong with my create function
"", "date" => "2012-07-09 15:59:53 -0700", "status" => ; "", "Result" = & gt; ""}, "1" => {"Test_id" = & gt; "3", "machine_id" => "", "Date" = & gt; "2012-07-09 15:59:53 -0700", "status" = & gt; "", "Result" = & gt; ""}, "2" => {"Test_id" = & gt; "6", "machine_id" = & gt; "", "Date" = & gt; "2012-07-09 15:59:53 -0700", "status" = & gt; "", "Result" = & gt; ""}, "3" => {"Test_id" = & gt; "7", "machine_id" => "", "Date" = & gt; "2012-07-09 15:" "," status "=>," "}}," date "= & gt;" 2012-07-09 15:59:53 -0700 "}," committed " = & Gt; "Send", "Action" = & gt; "Create Administrator", "" = & gt; "test_suite_runs"} @test_suite_num for an example variable and instead of putting it in a garter method (which is very weird and weird), get rid of that
before_filter and completely Remove the method from In fact, do not even use
@test_suite_num because it seems that you are not using it.
params [: number] as you used it for yourself.
puts params.to_s in your texture and let us know what happens when you submit a form. (Also, look as a footnote: What are the example variables in Ruby, because it seems that you are misusing them.)
Comments
Post a Comment