similar to: [rails] undefined method `model_name' for NilClass:Class

Displaying 20 results from an estimated 1000 matches similar to: "[rails] undefined method `model_name' for NilClass:Class"

2010 Apr 14
4
module/class question
Are these two below the same thing? 1. module X module Y class Z 2. class X::Y::Z -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to
2010 Jun 20
10
RSpec 2 view example: render_template
On http://github.com/rspec/rspec-rails under "View specs" there''s an example describe "events/index.html.erb" do it "renders _event partial for each event" do assign(:events, [stub_model(Event), stub_model(Event)]) render view.should render_template(:partial => "_event", :count => 2) end end Is this indeed correct? From the
2010 Dec 20
11
rails code to sql
Is there a relatively easy way to do this code in sql? @categories=Category.all.reject{|n| n.blank?}.sort{|a,b| a.name <=>b.name}.collect{|t| [t.name,t.name.downcase.gsub('' '',''_'')]} -- 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
2009 May 05
4
modalbox rails var interpolation
Howdy everyone. I am using modalbox which is very nice an easy to use. I have this for an edit for a company listing: <td><%= link_to(''Manage Companies'', {}, :onclick => ''Modalbox.show(\''/ companies/edit/#{company.id}\'', {width: 600}); return false;'') %></td> The link is not putting the company.id in it puts #{
2011 Aug 28
3
rspec-rails render_views doesn't render layouts? / how to check flash isn't rendered
I''m trying to test that "static" pages (they''re ERB, but get cached), generated through rails, don''t render any stray flash notices left over by the authentication system (Devise) or wherever else. I''ve tried writing this controller spec, but it appears that response.body only renders the template, not its layouts? describe "so that static
2008 Jun 24
1
Suggestions on how to use stub_model with webrat?
Hi all, I am using story runner with webrat, but I am not sure how to incorporate stub_model into my tests. The webrat steps only care about the user interface and have nothing to say about interaction with the database. Following Ben Mabey, I have a line in my story like: "When clicks the Create button" And a step like: When "clicks the $button button" do |button|
2009 Jul 19
3
Edit function now outputs HTML only
For some reason my new action works fine but my edit outputs nothing but raw HTML. Anyone have any ideas?
2011 May 28
4
how can I investigate when a rspec test fails?
For example: it "re-renders the ''new'' template" do # Trigger the behavior that occurs when invalid params are submitted Sector.any_instance.stub(:save).and_return(false) post :create, :sector => {} response.should render_template("new") end I have the new template under app/views/sectors but the test says: SectorsController POST
2008 Aug 26
9
stub_model() and ActiveRecord Associations
Hi all, I have what I thought was quite a simple requirement but something to do with the way ActiveRecord''s associations work is making it quite puzzling. I guess I can sum it up with this failing test: before(:each) do @source_comment = @source.comments.create(:user_id => 1) @target_comment = @target.comments.create(:user_id => 1) end
2011 Apr 13
3
Question about ERB performance
I''m trying out rails 3 and I''m looking at the performance statistics given by WEBrick. It says many of my database operations are taking 2ms or 7ms... but the view is taking 40ms. People often say that the database is the bottleneck in applications (which it most certainly can be, and often is)... but isn''t the rendering of ERB a little show here? My test pages really
2011 May 26
8
Is there a way I can create a sub-layout with ERB?
I have 2 pages that have almost the same content except for stuff in the middle. I''d basically like to have a sub-layout that wraps the content that is different - exactly the way a normal layout file would. How can I call into a layout inside of erb? I''d like to do something like this: <%= render :sub-layout => "reusable-wrapper" %>
2011 Jan 30
5
Named routes problem... more rails than rspec
Howdy, I have emailed before about the inconsistencies I''m spotting when using named routes/resource, but I think I''ve narrowed down the issue. It would seem this has nothing to do with rspec per se, but more with how routing works with rails. If you have an object instance, that isn''t saved and you attempt to generate a path for that item, even though the item may
2008 May 26
7
Mocking Models in Controller Specs...
I find myself doing this kind of thing a lot in Controller Specs: @vacancy = mock_model(Vacancy) @vacancy.stub!(:reference) @vacancy.stub!(:title) @vacancy.stub!(:created_at) @vacancy.stub!(:updated_at) @vacancy.stub!(:body) @vacancy.stub!(:contract) @vacancy.stub!(:location) @vacancy.stub!(:salary) @vacancy.stub!(:benefits)
2008 Jun 28
19
Stopping example execution?
Hello, I''m wondering If I am missing something here when creating an example that sets an expecation at the top or beginning of an action but requires you to stub / mock everything that follows. Example: I want to test that a certain controller is running a before_filter...thats easy: - controller.should_receive(:require_user) - do_get But now i''ve got to mock / stub
2011 Mar 06
2
render_views and render_to_string
Hey guys. One of my controller actions uses #render_to_string to send back a JSON response. When I try to spec this, Ruby raises a NoMethodError, saying that #render_to_string doesn''t exist in my controller action. Here''s the controller action, spec, and output: http://pastie.org/1640962 Any idea what I''m doing wrong? Thanks, Nick -------------- next part
2008 May 20
4
mock_model not stubbing model attribtues in view spec
Hi -- I am just getting to grips w/ view specs, and am having an issue with mock_model not stubbing the mocked model''s attributes. For instance, I have the following: <CODE> before do @input_timesheet = mock_model( InputTimesheet ) assigns[:input_timesheet] = @input_timesheet end it "should display a table element" do render
2007 Feb 16
6
some fun functionality for all your specs
I''ve found these two snippets of code useful and would love some feedback. first, .should_have_valid_associations usage: context "A new Product" do specify "should have valid associations" do @product.should_have_valid_associations end end code: (thanks to Wilson/Defiler for converting to rspec) module Spec module Expectations module Should
2011 Nov 18
1
What does :count actually mean in assert_select?
Hi guys, I tried reading up the RSPEC Book (Dec 2010) and googled a bit but I could not find anything. I''m using Rspec2. Example: spec/factories/categories.rb ====================== FactoryGirl.define do factory :category_intakes, :class => ''category'' do name ''intakes and filters'' description ''airfilters and
2008 Jul 28
3
getting error Unknown method 'new' for a new model instance
I have a model called Test. In the controller I have @circuit = Test.new. Any ideas why rails is complaining about the ''new'' method?? --~--~---------~--~----~------------~-------~--~----~ 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
2010 Aug 30
1
undefined method `route_for' for #<RSpec::Core::ExampleGroup::Nested_1::Nested_1:
Hello, all, I have this error with my rspec - controller - test, and yes, I do found the thread with the same error here, but it isn''t helped me, think it''s not my case. i have rails -v = Rails 3.0.0.rc, rspec -v = 2.0.0.beta.18 (hope they should match each other). my test is here: spec/controllers/posts_controller_spec.rb and i ran it with command: rspec