nomethoderror

Rails 3.2.3 namespaced controllers being overridden by global controllers with same name

不想你离开。 提交于 2019-12-23 08:28:20
问题 When the global application controller is loaded first, the namespaced application controller does not load when loading pages within that namespace. The application controller looks like this: class ApplicationController < ActionController::Base protect_from_forgery end And the namespaced application controller looks like this: class Admin::ApplicationController < ApplicationController def authenticate_admin! if current_admin.nil? redirect_to new_admin_session_url end end private def current

state_machine gem integration with rails 4

我们两清 提交于 2019-12-14 01:28:08
问题 I am facing a problem with usage of state_machine gem with my rails 4 app. A have a model which include a column call state as described in the provided rails tutorial http://gistflow.com/posts/679-state-machine-with-rails-basics but when I define my state_machine as follows: class Issue < ActiveRecord::Base validates :title, :description, presence: true has_many :notes state_machine :initial => :new do state :new, value: 0 state :analysed, value: 1 state :assigned, value: 2 state :inprogress

undefined method `items' for nil:NilClass in @cart.items.each

一世执手 提交于 2019-12-13 03:12:39
问题 These are my pruduct.rb, cart.eb and item.rb class Product < ActiveRecord::Base attr_accessible :category_id, :color, :description, :price, :size, :title, :product_type, :sub_category_id, :image_url belongs_to :category belongs_to :sub_category has_many :items end Cart.rb class Cart < ActiveRecord::Base has_many :items, dependent: :destroy end Item.rb class Item < ActiveRecord::Base attr_accessible :cart_id, :product_id,:product belongs_to :cart belongs_to :product end The ItemContoller class

Ruby: Private method called for 3:Fixnum

半腔热情 提交于 2019-12-12 22:10:29
问题 I am trying to learn the nuances of this simple function but am not sure what I need to do to fix this NoMethodError. How do I make 'split' public rather than private? Will that fix the problem? Here is my code: DATA = [3, 4, 5, 6, 7, 8] DATA.each do |line| vals = line.split print vals[0] + vals[1], " " end Here is the error message I get when I run this in IRB: NoMethodError: private method `split' called for 3:Fixnum 回答1: You are calling the method split on a number object — this method

Accessing Hash Keys with user inputted variables, NoMethodError

本秂侑毒 提交于 2019-12-12 06:29:27
问题 I get this error message when trying to access a hash with user inputted variables: "undefined method `index' for nil:NilClass (NoMethodError)" This should illustrate my problem a little better... once the string "n" is stored in a variable that variable can't access the hash anymore and returns nil. Why? [6] pry(main)> line = "n" => "n" [7] pry(main)> subway[:line] => nil [8] pry(main)> subway[:"n"] => ["timessquare", "34th", "28th", "23rd", "unionsquare", "8th"] [9] pry(main)> line => "n"

NoMethodError in Discussions#new

◇◆丶佛笑我妖孽 提交于 2019-12-12 04:09:05
问题 Can anyone help me to fix this?Thanks in advance! I get the following error: NoMethodError in Discussions#new Showing C:/Users/punitha/aggregator/app/views/discussions/_form.html.erb where line #1 raised: undefined method `discussions_index_path' for #<#<Class:0x4375758>:0x437d6d8> Extracted source (around line #1): 1 <%= form_for @discussions do |f| %> 2 <% if @discussions.errors.any? %> 3 <div id="error_explanation"> 4 <h2><%= pluralize(@discussions.errors.count, "error") %> prohibited

How to stop NoMethodError when clicking #new & #edit?

雨燕双飞 提交于 2019-12-12 03:07:29
问题 I'm having a hard time figuring out how to incorporate multiple controller's logic into a sidebar. For example, I want to have a section in the sidebar that uses @habits logic from the habits_controller and a section that uses @unaccomplished_goals logic from the goals_controller. For this question let's just focus on @unaccomplished_goals . <% @top_3_goals.each do |goal| %> shows correctly in the app's sidebar, which is derived from the goals_controller #index @top_3_goals = @unaccomplished

Hartl Rails Tutorial Chapter 8.46 NoMethodError

独自空忆成欢 提交于 2019-12-11 20:21:40
问题 one my my tests receiving the following error in Chapter 8 of Hartl's Rails Tutorial. > 1) Error: > UsersLoginTest#test_login_with_valid_information_followed_by_logout: > NoMethodError: undefined method `forget' for #<Class:0x000000079be3b0> > app/helpers/sessions_helper.rb:30:in `forget' > app/helpers/sessions_helper.rb:37:in `log_out' > app/controllers/sessions_controller.rb:18:in `destroy' > test/integration/users_login_test.rb:40:in `block in <class:UsersLoginTest>' I have tried copying

undefined method `new' for #<Grease::Adapter(Less::Rails::ImportProcessor)

主宰稳场 提交于 2019-12-11 16:15:06
问题 I have updated a gem in the Gemfile and started facing the Grease::Adapter error after running "bundle" command. The problem seems with the css of my application. The error is given below: NoMethodError: undefined method `new' for #<Grease::Adapter(Less::Rails::ImportProcessor):0x0000000205dfc0> I am using rails version "4.1.8". Can anyone help me how to resolve this? 回答1: The issue was resolved and it was due to the "grease" gem dependency for updated "less-rails" gem (v3.0.0). "Grease"

NoMethodError when trying to access method defined in included module

会有一股神秘感。 提交于 2019-12-10 14:45:09
问题 I'm trying to access a method from a module in one of my spec helpers I include the module in the test helper module Support class RestHelper include Rest::Rest def create_rest_client_for_ifa # Call method from module create_rest_client(uname, pword) end end end But I keep getting a NoMethodError when I run my spec: Failure/Error: @rest_client = Support::RestHelper.create_rest_client_for_ifa NoMethodError: undefined method `create_rest_client' for Support::RestHelper:Class Here is my module