I am working on a project that searches for an item number. But the
item number is not unique. Which is better to do:
/search/12345 or /search?id=12345 I would prefer to use the first
one.
I have a route for it as map.search "/search/:item_number"
I have made both work with manual testing. I do have a problem in
rSpec testing though. I do not understand how to request the page from
the controller.
I tried:
in the public_controller I have:
def search
@items = Item.all_items(params(:item_number))
....
end
and in the rspec for the controller:
describe PublicController do
#Delete these examples and add some real ones
it "should use PublicController" do
controller.should be_an_instance_of(PublicController)
end
describe "GET ''index''" do
it "should be successful" do
get ''index''
response.should be_success
end
end
describe "GET /search/:item_number" do
it "should be successful" do
get :search, :item_number => "12345" # also tried
''search''
response.should be_success
end
end
end
it errors with:
ArgumentError in ''PublicController GET /search/:item_number should be
successful''
wrong number of arguments (1 for 0)
where have I gone wrong?
Don French
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---
try get ''search'', { :item_number => "12345" }
On Jan 9, 2008 8:16 AM, dhf
<dhf0820-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
>
> I am working on a project that searches for an item number. But the
> item number is not unique. Which is better to do:
>
> /search/12345 or /search?id=12345 I would prefer to use the first
> one.
> I have a route for it as map.search "/search/:item_number"
>
> I have made both work with manual testing. I do have a problem in
> rSpec testing though. I do not understand how to request the page from
> the controller.
>
> I tried:
>
> in the public_controller I have:
>
> def search
> @items = Item.all_items(params(:item_number))
> ....
> end
>
> and in the rspec for the controller:
>
> describe PublicController do
>
> #Delete these examples and add some real ones
> it "should use PublicController" do
> controller.should be_an_instance_of(PublicController)
> end
>
>
> describe "GET ''index''" do
> it "should be successful" do
> get ''index''
> response.should be_success
> end
> end
>
> describe "GET /search/:item_number" do
> it "should be successful" do
> get :search, :item_number => "12345" # also tried
''search''
> response.should be_success
> end
> end
> end
>
> it errors with:
> ArgumentError in ''PublicController GET /search/:item_number should
be
> successful''
> wrong number of arguments (1 for 0)
>
> where have I gone wrong?
>
> Don French
>
>
> >
>
--
Ryan Bigg
http://www.frozenplague.net
Feel free to add me to MSN and/or GTalk as this email.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---
used: get "search", {:item_number => "12345"} and
it gave the
same error.
dhf
On Jan 8, 12:46 pm, "Ryan Bigg"
<radarliste...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:> try get ''search'', { :item_number => "12345"
}
>
> On Jan 9, 2008 8:16 AM, dhf
<dhf0...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
>
>
>
>
>
> > I am working on a project that searches for an item number. But the
> > item number is not unique. Which is better to do:
>
> > /search/12345 or /search?id=12345 I would prefer to use the first
> > one.
> > I have a route for it as map.search "/search/:item_number"
>
> > I have made both work with manual testing. I do have a problem in
> > rSpec testing though. I do not understand how to request the page from
> > the controller.
>
> > I tried:
>
> > in the public_controller I have:
>
> > def search
> > @items = Item.all_items(params(:item_number))
> > ....
> > end
>
> > and in the rspec for the controller:
>
> > describe PublicController do
>
> > #Delete these examples and add some real ones
> > it "should use PublicController" do
> > controller.should be_an_instance_of(PublicController)
> > end
>
> > describe "GET ''index''" do
> > it "should be successful" do
> > get ''index''
> > response.should be_success
> > end
> > end
>
> > describe "GET /search/:item_number" do
> > it "should be successful" do
> > get :search, :item_number => "12345" # also tried
''search''
> > response.should be_success
> > end
> > end
> > end
>
> > it errors with:
> > ArgumentError in ''PublicController GET /search/:item_number
should be
> > successful''
> > wrong number of arguments (1 for 0)
>
> > where have I gone wrong?
>
> > Don French
>
> --
> Ryan Bigghttp://www.frozenplague.net
> Feel free to add me to MSN and/or GTalk as this email.
--~--~---------~--~----~------------~-------~--~----~
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@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
Could I have the backtrace on the error please? On Jan 9, 2008 9:30 AM, dhf <dhf0820-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > used: get "search", {:item_number => "12345"} and it gave the > same error. > > dhf > > On Jan 8, 12:46pm, "Ryan Bigg" <radarliste...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > try get ''search'', { :item_number => "12345" } > > > > On Jan 9, 2008 8:16 AM, dhf <dhf0...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > > > > > > > > I am working on a project that searches for an item number. But the > > > item number is not unique. Which is better to do: > > > > > /search/12345 or /search?id=12345 I would prefer to use the first > > > one. > > > I have a route for it as map.search "/search/:item_number" > > > > > I have made both work with manual testing. I do have a problem in > > > rSpec testing though. I do not understand how to request the page from > > > the controller. > > > > > I tried: > > > > > in the public_controller I have: > > > > > def search > > > @items = Item.all_items(params(:item_number)) > > > .... > > > end > > > > > and in the rspec for the controller: > > > > > describe PublicController do > > > > > #Delete these examples and add some real ones > > > it "should use PublicController" do > > > controller.should be_an_instance_of(PublicController) > > > end > > > > > describe "GET ''index''" do > > > it "should be successful" do > > > get ''index'' > > > response.should be_success > > > end > > > end > > > > > describe "GET /search/:item_number" do > > > it "should be successful" do > > > get :search, :item_number => "12345" # also tried ''search'' > > > response.should be_success > > > end > > > end > > > end > > > > > it errors with: > > > ArgumentError in ''PublicController GET /search/:item_number should be > > > successful'' > > > wrong number of arguments (1 for 0) > > > > > where have I gone wrong? > > > > > Don French > > > > -- > > Ryan Bigghttp://www.frozenplague.net > > Feel free to add me to MSN and/or GTalk as this email. > > >-- Ryan Bigg http://www.frozenplague.net Feel free to add me to MSN and/or GTalk as this email. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
We can talk gtalk if you want. /Users/dhf/NetBeansProjects/snr/app/controllers/public_controller.rb: 8:in `params'' /Users/dhf/NetBeansProjects/snr/app/controllers/public_controller.rb: 8:in `search'' /Library/Ruby/Gems/1.8/gems/actionpack-2.0.2/lib/action_controller/ base.rb:1158:in `send'' /Library/Ruby/Gems/1.8/gems/actionpack-2.0.2/lib/action_controller/ base.rb:1158:in `perform_action_without_filters'' /Library/Ruby/Gems/1.8/gems/actionpack-2.0.2/lib/action_controller/ filters.rb:697:in `call_filters'' /Library/Ruby/Gems/1.8/gems/actionpack-2.0.2/lib/action_controller/ filters.rb:689:in `perform_action_without_benchmark'' /Library/Ruby/Gems/1.8/gems/actionpack-2.0.2/lib/action_controller/ benchmarking.rb:68:in `perform_action_without_rescue'' /Library/Ruby/Gems/1.8/gems/actionpack-2.0.2/lib/action_controller/ benchmarking.rb:68:in `perform_action_without_rescue'' /Library/Ruby/Gems/1.8/gems/actionpack-2.0.2/lib/action_controller/ rescue.rb:199:in `perform_action_without_caching'' /Library/Ruby/Gems/1.8/gems/actionpack-2.0.2/lib/action_controller/ caching.rb:678:in `perform_action'' /Library/Ruby/Gems/1.8/gems/activerecord-2.0.2/lib/active_record/ connection_adapters/abstract/query_cache.rb:33:in `cache'' /Library/Ruby/Gems/1.8/gems/activerecord-2.0.2/lib/active_record/ query_cache.rb:8:in `cache'' /Library/Ruby/Gems/1.8/gems/actionpack-2.0.2/lib/action_controller/ caching.rb:677:in `perform_action'' /Library/Ruby/Gems/1.8/gems/actionpack-2.0.2/lib/action_controller/ base.rb:524:in `send'' /Library/Ruby/Gems/1.8/gems/actionpack-2.0.2/lib/action_controller/ base.rb:524:in `process_without_filters'' /Library/Ruby/Gems/1.8/gems/actionpack-2.0.2/lib/action_controller/ filters.rb:685:in `process_without_session_management_support'' /Library/Ruby/Gems/1.8/gems/actionpack-2.0.2/lib/action_controller/ session_management.rb:123:in `process_without_test'' /Library/Ruby/Gems/1.8/gems/actionpack-2.0.2/lib/action_controller/ test_process.rb:15:in `process'' /Library/Ruby/Gems/1.8/gems/actionpack-2.0.2/lib/action_controller/ test_process.rb:393:in `process'' /Library/Ruby/Gems/1.8/gems/actionpack-2.0.2/lib/action_controller/ test_process.rb:364:in `get'' ./spec/controllers/public_controller_spec.rb:20: On Jan 8, 1:02 pm, "Ryan Bigg" <radarliste...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Could I have the backtrace on the error please? > > On Jan 9, 2008 9:30 AM, dhf <dhf0...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > > used: get "search", {:item_number => "12345"} and it gave the > > same error. > > > dhf > > > On Jan 8, 12:46pm, "Ryan Bigg" <radarliste...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > try get ''search'', { :item_number => "12345" } > > > > On Jan 9, 2008 8:16 AM, dhf <dhf0...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > I am working on a project that searches for an item number. But the > > > > item number is not unique. Which is better to do: > > > > > /search/12345 or /search?id=12345 I would prefer to use the first > > > > one. > > > > I have a route for it as map.search "/search/:item_number" > > > > > I have made both work with manual testing. I do have a problem in > > > > rSpec testing though. I do not understand how to request the page from > > > > the controller. > > > > > I tried: > > > > > in the public_controller I have: > > > > > def search > > > > @items = Item.all_items(params(:item_number)) > > > > .... > > > > end > > > > > and in the rspec for the controller: > > > > > describe PublicController do > > > > > #Delete these examples and add some real ones > > > > it "should use PublicController" do > > > > controller.should be_an_instance_of(PublicController) > > > > end > > > > > describe "GET ''index''" do > > > > it "should be successful" do > > > > get ''index'' > > > > response.should be_success > > > > end > > > > end > > > > > describe "GET /search/:item_number" do > > > > it "should be successful" do > > > > get :search, :item_number => "12345" # also tried ''search'' > > > > response.should be_success > > > > end > > > > end > > > > end > > > > > it errors with: > > > > ArgumentError in ''PublicController GET /search/:item_number should be > > > > successful'' > > > > wrong number of arguments (1 for 0) > > > > > where have I gone wrong? > > > > > Don French > > > > -- > > > Ryan Bigghttp://www.frozenplague.net > > > Feel free to add me to MSN and/or GTalk as this email. > > -- > Ryan Bigghttp://www.frozenplague.net > Feel free to add me to MSN and/or GTalk as this email.--~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Log file shows:
Processing PublicController#search (for 0.0.0.0 at 2008-01-08
13:15:29) [GET]
Session ID:
Parameters: {"action"=>"search",
"controller"=>"public",
"item_number"=>"12345"}
SQL (0.000206) ROLLBACK
On Jan 8, 1:14 pm, dhf <dhf0...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:> We can talk gtalk if you want.
>
> /Users/dhf/NetBeansProjects/snr/app/controllers/public_controller.rb:
> 8:in `params''
> /Users/dhf/NetBeansProjects/snr/app/controllers/public_controller.rb:
> 8:in `search''
> /Library/Ruby/Gems/1.8/gems/actionpack-2.0.2/lib/action_controller/
> base.rb:1158:in `send''
> /Library/Ruby/Gems/1.8/gems/actionpack-2.0.2/lib/action_controller/
> base.rb:1158:in `perform_action_without_filters''
> /Library/Ruby/Gems/1.8/gems/actionpack-2.0.2/lib/action_controller/
> filters.rb:697:in `call_filters''
> /Library/Ruby/Gems/1.8/gems/actionpack-2.0.2/lib/action_controller/
> filters.rb:689:in `perform_action_without_benchmark''
> /Library/Ruby/Gems/1.8/gems/actionpack-2.0.2/lib/action_controller/
> benchmarking.rb:68:in `perform_action_without_rescue''
> /Library/Ruby/Gems/1.8/gems/actionpack-2.0.2/lib/action_controller/
> benchmarking.rb:68:in `perform_action_without_rescue''
> /Library/Ruby/Gems/1.8/gems/actionpack-2.0.2/lib/action_controller/
> rescue.rb:199:in `perform_action_without_caching''
> /Library/Ruby/Gems/1.8/gems/actionpack-2.0.2/lib/action_controller/
> caching.rb:678:in `perform_action''
> /Library/Ruby/Gems/1.8/gems/activerecord-2.0.2/lib/active_record/
> connection_adapters/abstract/query_cache.rb:33:in `cache''
> /Library/Ruby/Gems/1.8/gems/activerecord-2.0.2/lib/active_record/
> query_cache.rb:8:in `cache''
> /Library/Ruby/Gems/1.8/gems/actionpack-2.0.2/lib/action_controller/
> caching.rb:677:in `perform_action''
> /Library/Ruby/Gems/1.8/gems/actionpack-2.0.2/lib/action_controller/
> base.rb:524:in `send''
> /Library/Ruby/Gems/1.8/gems/actionpack-2.0.2/lib/action_controller/
> base.rb:524:in `process_without_filters''
> /Library/Ruby/Gems/1.8/gems/actionpack-2.0.2/lib/action_controller/
> filters.rb:685:in `process_without_session_management_support''
> /Library/Ruby/Gems/1.8/gems/actionpack-2.0.2/lib/action_controller/
> session_management.rb:123:in `process_without_test''
> /Library/Ruby/Gems/1.8/gems/actionpack-2.0.2/lib/action_controller/
> test_process.rb:15:in `process''
> /Library/Ruby/Gems/1.8/gems/actionpack-2.0.2/lib/action_controller/
> test_process.rb:393:in `process''
> /Library/Ruby/Gems/1.8/gems/actionpack-2.0.2/lib/action_controller/
> test_process.rb:364:in `get''
> ./spec/controllers/public_controller_spec.rb:20:
>
> On Jan 8, 1:02 pm, "Ryan Bigg"
<radarliste...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
>
> > Could I have the backtrace on the error please?
>
> > On Jan 9, 2008 9:30 AM, dhf
<dhf0...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
>
> > > used: get "search", {:item_number =>
"12345"} and it gave the
> > > same error.
>
> > > dhf
>
> > > On Jan 8, 12:46pm, "Ryan Bigg"
<radarliste...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
> > > > try get ''search'', { :item_number =>
"12345" }
>
> > > > On Jan 9, 2008 8:16 AM, dhf
<dhf0...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
>
> > > > > I am working on a project that searches for an item
number. But the
> > > > > item number is not unique. Which is better to do:
>
> > > > > /search/12345 or /search?id=12345 I would prefer to use
the first
> > > > > one.
> > > > > I have a route for it as map.search
"/search/:item_number"
>
> > > > > I have made both work with manual testing. I do have a
problem in
> > > > > rSpec testing though. I do not understand how to
request the page from
> > > > > the controller.
>
> > > > > I tried:
>
> > > > > in the public_controller I have:
>
> > > > > def search
> > > > > @items = Item.all_items(params(:item_number))
> > > > > ....
> > > > > end
>
> > > > > and in the rspec for the controller:
>
> > > > > describe PublicController do
>
> > > > > #Delete these examples and add some real ones
> > > > > it "should use PublicController" do
> > > > > controller.should be_an_instance_of(PublicController)
> > > > > end
>
> > > > > describe "GET ''index''" do
> > > > > it "should be successful" do
> > > > > get ''index''
> > > > > response.should be_success
> > > > > end
> > > > > end
>
> > > > > describe "GET /search/:item_number" do
> > > > > it "should be successful" do
> > > > > get :search, :item_number => "12345" #
also tried ''search''
> > > > > response.should be_success
> > > > > end
> > > > > end
> > > > > end
>
> > > > > it errors with:
> > > > > ArgumentError in ''PublicController GET
/search/:item_number should be
> > > > > successful''
> > > > > wrong number of arguments (1 for 0)
>
> > > > > where have I gone wrong?
>
> > > > > Don French
>
> > > > --
> > > > Ryan Bigghttp://www.frozenplague.net
> > > > Feel free to add me to MSN and/or GTalk as this email.
>
> > --
> > Ryan Bigghttp://www.frozenplague.net
> > Feel free to add me to MSN and/or GTalk as this email.
--~--~---------~--~----~------------~-------~--~----~
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@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---