I''ve experimented around and have ran out of ideas, here''s the
message:
TypeError in True_false_questions#list
can''t convert String into Integer
RAILS_ROOT: script/../config/..
Application Trace <http://zbyte32:3000/true_false_questions/list/0#> |
Framework
Trace <http://zbyte32:3000/true_false_questions/list/0#> | Full
Trace<http://zbyte32:3000/true_false_questions/list/0#>
./script/../config/../app/controllers/true_false_questions_controller.rb:9:in
`[]''
here''s the code snippet:
class TrueFalseQuestionsController < ApplicationController
def index
list
render :action => ''list''
end
def list
if params[:id]
@true_false_question_pages, @true_false_questions = paginate
TrueFalseQuestion.find_all["tests_id = ?"+ params[:id]], :per_page
=> 10
else
@true_false_question_pages, @true_false_questions = paginate
:true_false_questions, :per_page => 10
end
end
basically vist the url: http://zbyte32:3000/true_false_questions/list/0
any suggestions would be much apreciated. Thank you.
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
http://wrath.rubyonrails.org/pipermail/rails/attachments/20060125/1e747390/attachment.html
I think you want:
if params[:id]
@true_false_question_pages, @true_false_questions paginate
TrueFalseQuestion.find( :all,
:conditions => ["tests_id = ?", [params[:id]]]),
:per_page => 10
Or better, if you''ve got the associations set up:
if params[:id]
@true_false_question_pages, @true_false_questions paginate
Test.find(params[:id]).true_false_questions,
:per_page => 10
--
Alex
zbyte pepsi-hola wrote:> I''ve experimented around and have ran out of ideas,
here''s the message:
>
>
> TypeError in True_false_questions#list
>
> can''t convert String into Integer
>
> |RAILS_ROOT: script/../config/..|
>
> Application Trace <http://zbyte32:3000/true_false_questions/list/0#>
|
> Framework Trace <http://zbyte32:3000/true_false_questions/list/0#> |
> Full Trace <http://zbyte32:3000/true_false_questions/list/0#>
>
>
|./script/../config/../app/controllers/true_false_questions_controller.rb:9:in
`[]''
>
> here''s the code snippet:
>
>
> |
>
> class TrueFalseQuestionsController < ApplicationController
> def index
> list
> render :action => ''list''
> end
>
> def list
> if params[:id]
> @true_false_question_pages, @true_false_questions = paginate
> TrueFalseQuestion.find_all["tests_id = ?"+ params[:id]],
:per_page => 10
> else
> @true_false_question_pages, @true_false_questions = paginate
> :true_false_questions, :per_page => 10
> end
> end
>
> basically vist the url: http://zbyte32:3000/true_false_questions/list/0
>
> any suggestions would be much apreciated. Thank you.
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Rails mailing list
> Rails@lists.rubyonrails.org
> http://lists.rubyonrails.org/mailman/listinfo/rails
hmm, now i get: NameError in True_false_questions#list "#<TrueFalseQuestion:0xb73d616c>" is not a valid constant name! RAILS_ROOT: script/../config/.. Application Trace <http://zbyte32:3000/true_false_questions/list/0#> | Framework Trace <http://zbyte32:3000/true_false_questions/list/0#> | Full Trace<http://zbyte32:3000/true_false_questions/list/0#> /usr/lib/ruby/gems/1.8/gems/activesupport-1.2.5/lib/active_support/core_ext/integer/../../inflector.rb:145:in `constantize'' /usr/lib/ruby/gems/1.8/gems/activesupport-1.2.5/lib/active_support/core_ext/string/inflections.rb:52:in `constantize'' /usr/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/pagination.rb:186:in `paginator_and_collection_for'' /usr/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/pagination.rb:124:in `paginate'' ./script/../config/../app/controllers/true_false_questions_controller.rb:9:in `list'' just to clariy, tests_id is a foreign key. On 1/25/06, Alex Young <alex@blackkettle.org> wrote:> > I think you want: > > if params[:id] > @true_false_question_pages, @true_false_questions > paginate TrueFalseQuestion.find( :all, > :conditions => ["tests_id = ?", [params[:id]]]), > :per_page => 10 > > Or better, if you''ve got the associations set up: > > if params[:id] > @true_false_question_pages, @true_false_questions > paginate Test.find(params[:id]).true_false_questions, > :per_page => 10 > > -- > Alex > > zbyte pepsi-hola wrote: > > I''ve experimented around and have ran out of ideas, here''s the message: > > > > > > TypeError in True_false_questions#list > > > > can''t convert String into Integer > > > > |RAILS_ROOT: script/../config/..| > > > > Application Trace <http://zbyte32:3000/true_false_questions/list/0#> | > > Framework Trace <http://zbyte32:3000/true_false_questions/list/0#> | > > Full Trace <http://zbyte32:3000/true_false_questions/list/0#> > > > > > |./script/../config/../app/controllers/true_false_questions_controller.rb:9:in > `[]'' > > > > here''s the code snippet: > > > > > > | > > > > class TrueFalseQuestionsController < ApplicationController > > def index > > list > > render :action => ''list'' > > end > > > > def list > > if params[:id] > > @true_false_question_pages, @true_false_questions = paginate > > TrueFalseQuestion.find_all["tests_id = ?"+ params[:id]], :per_page => 10 > > else > > @true_false_question_pages, @true_false_questions = paginate > > :true_false_questions, :per_page => 10 > > end > > end > > > > basically vist the url: http://zbyte32:3000/true_false_questions/list/0 > > > > any suggestions would be much apreciated. Thank you. > > > > > > ------------------------------------------------------------------------ > > > > _______________________________________________ > > Rails mailing list > > Rails@lists.rubyonrails.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060125/44aef5d7/attachment.html
I am sorry, but I am rather new to ruby, I am not exactly sure what is wrong with the code you gave me, I am sure I typed it in properly On 1/25/06, zbyte pepsi-hola <zbyte64@gmail.com> wrote:> > hmm, now i get: > > NameError in True_false_questions#list > > "#<TrueFalseQuestion:0xb73d616c>" is not a valid constant name! > > RAILS_ROOT: script/../config/.. > Application Trace <http://zbyte32:3000/true_false_questions/list/0#> | Framework > Trace <http://zbyte32:3000/true_false_questions/list/0#> | Full Trace<http://zbyte32:3000/true_false_questions/list/0#> > > /usr/lib/ruby/gems/1.8/gems/activesupport-1.2.5/lib/active_support/core_ext/integer/../../inflector.rb:145:in `constantize'' > /usr/lib/ruby/gems/1.8/gems/activesupport-1.2.5/lib/active_support/core_ext/string/inflections.rb:52:in `constantize'' > > /usr/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/pagination.rb:186:in `paginator_and_collection_for'' > /usr/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/pagination.rb:124:in `paginate'' > > ./script/../config/../app/controllers/true_false_questions_controller.rb:9:in `list'' > > > just to clariy, tests_id is a foreign key. > > > On 1/25/06, Alex Young <alex@blackkettle.org> wrote: > > > > I think you want: > > > > if params[:id] > > @true_false_question_pages, @true_false_questions > > paginate TrueFalseQuestion.find( :all, > > :conditions => ["tests_id = ?", [params[:id]]]), > > :per_page => 10 > > > > Or better, if you''ve got the associations set up: > > > > if params[:id] > > @true_false_question_pages, @true_false_questions > > paginate Test.find(params[:id]).true_false_questions, > > :per_page => 10 > > > > -- > > Alex > > > > zbyte pepsi-hola wrote: > > > I''ve experimented around and have ran out of ideas, here''s the > > message: > > > > > > > > > TypeError in True_false_questions#list > > > > > > can''t convert String into Integer > > > > > > |RAILS_ROOT: script/../config/..| > > > > > > Application Trace <http://zbyte32:3000/true_false_questions/list/0#> | > > > Framework Trace < http://zbyte32:3000/true_false_questions/list/0#> | > > > Full Trace <http://zbyte32:3000/true_false_questions/list/0# > > > > > > > > > |./script/../config/../app/controllers/true_false_questions_controller.rb:9:in > > `[]'' > > > > > > here''s the code snippet: > > > > > > > > > | > > > > > > class TrueFalseQuestionsController < ApplicationController > > > def index > > > list > > > render :action => ''list'' > > > end > > > > > > def list > > > if params[:id] > > > @true_false_question_pages, @true_false_questions = paginate > > > TrueFalseQuestion.find_all["tests_id = ?"+ params[:id]], :per_page => > > 10 > > > else > > > @true_false_question_pages, @true_false_questions = paginate > > > :true_false_questions, :per_page => 10 > > > end > > > end > > > > > > basically vist the url: > > http://zbyte32:3000/true_false_questions/list/0 > > > > > > any suggestions would be much apreciated. Thank you. > > > > > > > > > > > ------------------------------------------------------------------------ > > > > > > _______________________________________________ > > > Rails mailing list > > > Rails@lists.rubyonrails.org > > > http://lists.rubyonrails.org/mailman/listinfo/rails > > _______________________________________________ > > Rails mailing list > > Rails@lists.rubyonrails.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060125/3a1652ba/attachment-0001.html
zbyte pepsi-hola wrote:> I am sorry, but I am rather new to ruby, I am not exactly sure what is > wrong with the code you gave me, I am sure I typed it in properlyI was just typing from memory, so there may well be a blooper in there somewhere. Was it the first or second that you tried? I''m guessing it was the second... Can you post your true_false_question.rb and test.rb files? -- Alex
i couldn''t find what was wrong, but i tried a different approach and it workd: @true_false_question_pages, @true_false_questions = paginate :true_false_questions, :conditions => ["tests_id = ?", params[:id]], :per_page => 10 On 1/25/06, zbyte pepsi-hola <zbyte64@gmail.com> wrote:> > I am sorry, but I am rather new to ruby, I am not exactly sure what is > wrong with the code you gave me, I am sure I typed it in properly > > On 1/25/06, zbyte pepsi-hola <zbyte64@gmail.com > wrote: > > > > hmm, now i get: > > > > NameError in True_false_questions#list > > > > "#<TrueFalseQuestion:0xb73d616c>" is not a valid constant name! > > > > RAILS_ROOT: script/../config/.. > > Application Trace <http://zbyte32:3000/true_false_questions/list/0#> | Framework > > Trace <http://zbyte32:3000/true_false_questions/list/0#> | Full Trace<http://zbyte32:3000/true_false_questions/list/0#> > > > > /usr/lib/ruby/gems/1.8/gems/activesupport-1.2.5/lib/active_support/core_ext/integer/../../inflector.rb:145:in `constantize'' > > /usr/lib/ruby/gems/1.8/gems/activesupport-1.2.5/lib/active_support/core_ext/string/inflections.rb:52:in `constantize'' > > > > > > /usr/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/pagination.rb:186:in `paginator_and_collection_for'' > > /usr/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/pagination.rb:124:in `paginate'' > > > > > > ./script/../config/../app/controllers/true_false_questions_controller.rb:9:in `list'' > > > > > > just to clariy, tests_id is a foreign key. > > > > > > On 1/25/06, Alex Young <alex@blackkettle.org > wrote: > > > > > > I think you want: > > > > > > if params[:id] > > > @true_false_question_pages, @true_false_questions > > > paginate TrueFalseQuestion.find( :all, > > > :conditions => ["tests_id = ?", [params[:id]]]), > > > :per_page => 10 > > > > > > Or better, if you''ve got the associations set up: > > > > > > if params[:id] > > > @true_false_question_pages, @true_false_questions > > > paginate Test.find(params[:id]).true_false_questions, > > > :per_page => 10 > > > > > > -- > > > Alex > > > > > > zbyte pepsi-hola wrote: > > > > I''ve experimented around and have ran out of ideas, here''s the > > > message: > > > > > > > > > > > > TypeError in True_false_questions#list > > > > > > > > can''t convert String into Integer > > > > > > > > |RAILS_ROOT: script/../config/..| > > > > > > > > Application Trace <http://zbyte32:3000/true_false_questions/list/0# > > > > | > > > > Framework Trace < http://zbyte32:3000/true_false_questions/list/0#> > > > | > > > > Full Trace < http://zbyte32:3000/true_false_questions/list/0# > > > > > > > > > > > > |./script/../config/../app/controllers/true_false_questions_controller.rb:9:in > > > `[]'' > > > > > > > > here''s the code snippet: > > > > > > > > > > > > | > > > > > > > > class TrueFalseQuestionsController < ApplicationController > > > > def index > > > > list > > > > render :action => ''list'' > > > > end > > > > > > > > def list > > > > if params[:id] > > > > @true_false_question_pages, @true_false_questions = paginate > > > > TrueFalseQuestion.find_all["tests_id = ?"+ params[:id]], :per_page > > > => 10 > > > > else > > > > @true_false_question_pages, @true_false_questions = paginate > > > > :true_false_questions, :per_page => 10 > > > > end > > > > end > > > > > > > > basically vist the url: http://zbyte32:3000/true_false_questions/list/0 > > > > > > > > > > > any suggestions would be much apreciated. Thank you. > > > > > > > > > > > > > > > ------------------------------------------------------------------------ > > > > > > > > _______________________________________________ > > > > Rails mailing list > > > > Rails@lists.rubyonrails.org > > > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > _______________________________________________ > > > Rails mailing list > > > Rails@lists.rubyonrails.org > > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > > > > >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060125/500db0ea/attachment.html
I tried both :) the error you see is from the first. I am currently at school but i will post the files once i get home. On 1/25/06, Alex Young <alex@blackkettle.org> wrote:> > zbyte pepsi-hola wrote: > > I am sorry, but I am rather new to ruby, I am not exactly sure what is > > wrong with the code you gave me, I am sure I typed it in properly > I was just typing from memory, so there may well be a blooper in there > somewhere. Was it the first or second that you tried? I''m guessing it > was the second... Can you post your true_false_question.rb and test.rb > files? > > -- > Alex > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060126/fdddb217/attachment.html