Displaying 15 results from an estimated 15 matches for "itemscontroller".
2007 Sep 18
2
rSpec / Nested Routes / Mocks
I''m having a terrible time trying to test a nested route with rSpec.
I can''t seem to tell rSpec to expect the call @item.user. The
following error message plagues me not matter how I try to fuss with
the mock:
Spec::Mocks::MockExpectationError in ''ItemsController handling POST /
items should redirect to the new course on successful save''
Mock ''Item_1002'' received unexpected message :user= with (#<User:
0x..fdb7bcd38 @name="User_1003">)
Any help would be greatly appreciated.
Here''s my setup. Problem lin...
2006 Aug 24
2
Design questions on creating digg.com-like URLs (are they considered RESTful?)
...fore)
I guess some obvious other ones are /users/:username/tags/:tags/:when
and /users/:username/friends/:tags/:when
So given this URL design system, what kind of routes would one need and
approximately how many actions (spread out over how many controllers -
should I just have them all in the ItemsController)? I''m currently
thinking of having four actions under the ItemsController (tags, view,
user, userfriends), but I''m not sure if this is enough or too many.
Because other than the top tab/subtab part of the view everything
beneath that is the same (summaries of the items).
Ap...
2011 Jul 14
0
subclasses with inherited_resources?
...so far so good. However, one
problem I''ve run into is that it''s very difficult to customize
inherited_resource behaviour in subclasses. Looking through the
source I see it uses things like undef_method and class_attribute.
For example, if I have the following controllers:
class ItemsController
inherit_resources
actions :new, :create
def create
# custom stuff here
creat!
end
end
class VideoController < ItemsController
actions :new, :create, :show
end
videos controller will not respond to /show because
inherited_resources undefined it in ItemsController. One thin...
2007 Oct 26
3
Specing with Subdomains as Account Keys
...riginally posted under "Mocking/Stubbing help
with subdomain as account key"
- http://rubyforge.org/pipermail/rspec-users/2007-October/
004138.html, but I''ve rephrased it to make it more clear with the
subdomain as account key question.)
# items_controller_spec.rb
describe ItemsController, "handling GET /items" do
fixtures :companies
before do
@request.host = "subdomain.test.host"
@item = mock(Item)
Item.stub!(:find).and_return([@item])
@current_company = mock(Company)
@current_company.stub!(:items).and_return([])
@current_com...
2009 Apr 19
1
Cucmber: Mysql::Error: query: not connected: ROLLBACK
...re-file looks like
Scenario: Create Valid Item
Given I start
and the step is
Given /^I start$/ do
get "/items"
end
In my log/test.log I get
SQL (0.2ms) SET NAMES ''utf8''
SQL (0.2ms) SET SQL_AUTO_IS_NULL=0
SQL (0.1ms) BEGIN
Processing ItemsController#index (for 127.0.0.1 at 2009-04-19 20:54:08)
[GET]
Item Load (0.2ms) SELECT * FROM `items`
Rendering template within layouts/application
Rendering items/index
Completed in 41ms (View: 30, DB: 1) | 200 OK [http://www.example.com/items]
SQL (0.0ms) Mysql::Error: query: not connected: ROLLB...
2007 Mar 21
0
Getting the module name with ObjectSpace...
...his case, I can extract the
controller names like,
@controllers
ObjectSpace.subclasses_of(ActionController::Base).each do |obj|
@controllers["#{obj.controller_name}"] = obj
end
However, now I''ve divided the site into modules, that is, I have for
instance both Store::ItemsController and Manage::ItemsController,
which reside in app/controllers/store and app/controllers/manage
respectively.
This causes my code above to basically (as it seems) discard the
"duplicate" controllers when traversing the classes. What I''d like to
do is mimic the hierarchy in my modu...
2009 May 03
0
HTTP Auth 401 Even on Valid Login
...'s the controllers:
class Admin::BaseController < ApplicationController
before_filter :authenticate
def authenticate
authenticate_or_request_with_http_basic do |name, pass|
name == ''h'' && pass == ''x''
end
end
end
class Admin::ItemsController < Admin::BaseController
def new
@item = Item.new
@category = ''New Item''
@categories = Category.find :all, :order=>''name''
end
#etc...
end
The log:
Processing ItemsController#new (for localhost at 2009-05-03 12:20:05)
[GET]
Session ID:...
2008 Oct 03
1
fragment caching with search box
I''m trying to setup some fragment caching which works fine for the index
but i''m not sure how to ignore the caching if they are searching the
index results.
my code in short:
ItemsController
def index
@items = Item.search(params[:search], params[:min_rank],
params[:max_rank], params[:classification_id], ...)
end
index.html.erb
<% cache (''items'', {:page => params[:page] || 1}) do %>
<% for item in @items %>
...show output
<% end %>
<...
2009 May 02
10
Problem verifying routing error
...does
exist (which *should* fail), I get the same result for those :except
actions as for a made-up action name. Seems this must have something to
do with the change in how route_for delegates back to ActionController''s
routing assertion (sez the backtrace :).
NoMethodError in ''ItemsController route generation should NOT map
#indewfefwex''
You have a nil object when you didn''t expect it!
You might have expected an instance of Array.
The error occurred while evaluating nil.first
/Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/assertions/routing_assertio...
2009 Sep 24
8
Drop down list ?
Hi Gurus, I''m trying to tackle a drop down list. I have category and
item dbs, and they''re wired up with category has_many :items and item
belongs_to :category, and an item has a category_id. I have this code
in my new/edit.html.erb for item:
<%= f.collection_select :category_id,
Category.find_main, :id, :header, {}, :multiple => false %>
And a pretty drop down list
2006 Apr 04
2
HABTM
...y :users
end
class User < ActiveRecord::Base
attr_accessor :new_password
has_and_belongs_to_many :items
[........]
end
items/list.rhtml:
[....]
<td><%=3D link_to ''=C3'', :action =3D> ''select'', :id =3D> item %></td>
[....]
class ItemsController < ApplicationController
[....]
def select
@user =3D @session[''user'']
item =3D Item.find(@params[:id])
@user.items =3D Item.find(@params[:id]) =20
#<<--------this is the erroneous line of code!
redirect_to :action =3D> ''...
2006 Apr 05
1
select in *.rhtml
I''m trying to get a select box of categories to appear in my items views
after I created everything using generate scaffold, but I can''t get the
categories to appear in my forms.
class ItemsController < ApplicationController
def new
@item = Item.new
@category = Category.find_all
end
...
class Item < ActiveRecord::Base
belongs_to :category
end
class Category < ActiveRecord::Base
has_many :items
end
I found some news postings that said the select tag in my _forms.r...
2008 May 08
0
Controller/action not working in url
...:delete %></td>
so when i click on this link, delete function in sale_items controller
is called. i.e.
def delete
--delete code--
redirect_to ( :action => ''saleedit'')
end
this is not working. it shows an error -->
ActiveRecord::RecordNotFound in Sale itemsController#show
it is unable to search "saleedit" function and by default goes to show
methos (default function-when no method is found it goes to show
method). please help me out why it is unable to find the method.
in url it is taking "saleedit" as an id (parameter) rathe than an
action...
2009 Aug 07
2
paperclip model fails while when updating with no attachment
...me item record with no attachment OR if I created an item record with
no attachment and then update the same item record with an attachment.
Basically - Once an asset has been attached to an item record, updating
with no attachment yields the following error:
"ActiveRecord::RecordInvalid in ItemsController#update
Validation failed: Attachment file name can''t be blank, Attachment file
size can''t be blank"
There are validation errors from the Assets Model for the presence of
:attachment_file_name and :attachment_file_size.
I have the below code in my item model:
[code]
aft...
2006 Sep 07
21
Multiple rails apps with Mongrel
I''m trying to set up several different Rails apps on the same domain, each
one running Mongrel. After reading all of the documentation, it''s fairly
clear how to use subdomains - create several Apache virtual hosts, each of
which has a different ProxyPass and ProxyPassReverse command to redirect
from different ports (ie, 3000, 3100), and then have each Mongrel instance
(or