Skip to content
This repository has been archived by the owner on Feb 26, 2020. It is now read-only.

NoMethodError for current_order(true) #6

Open
obates opened this issue Feb 26, 2014 · 3 comments
Open

NoMethodError for current_order(true) #6

obates opened this issue Feb 26, 2014 · 3 comments

Comments

@obates
Copy link

obates commented Feb 26, 2014

Hi,
I'm getting a "NoMethodError in Spree::Products#index", undefined method `[]' for true:TrueClass"

for the line

"<% order = current_order(true) %>"

in the file

.bundler/ruby/2.0.0/spree-3233ae973a97/frontend/app/views/spree/products/index.html.erb file after installing this gem.

Any ideas?

Many thanks,

Oli

screen shot 2014-02-26 at 19 54 15

@frankmt
Copy link
Contributor

frankmt commented Feb 26, 2014

Hi @obates,

thanks for reporting this. Not sure what it could be at the moment, and it's definitely not happening for our app.

Are you able to reproduce this in a clean spree app?

Also, could you post the stacktrace of the error and a copy fo your Gemfile? Can't really figure out where it is happening just from what you've sent me.

Cheers
Francisco

@obates
Copy link
Author

obates commented Mar 3, 2014

Yeah sure:

Deface: 2 overrides found for 'spree/shared/_products'
Deface: 'add_recently_viewed_products_to_products_index' matched 1 times with '#products[data-hook], [data-hook='products']'
Deface: [WARNING] No :original defined for 'add_recently_viewed_products_to_products_index', you should change its definition to include:
 :original => '079ebb01320e7f72d80c8225cd35c60bd4d9db3a'
Deface: 'quick_cart_add_button' matched 1 times with '#products span.price'
Deface: [WARNING] No :original defined for 'quick_cart_add_button', you should change its definition to include:
 :original => '075adef7261d00170c52ce0417dfa588caab669e'
  Rendered /Users/Oli/.bundler/ruby/2.0.0/spree-3233ae973a97/frontend/app/views/spree/shared/_products.html.erb (561.8ms)
  Rendered /Users/Oli/.bundler/ruby/2.0.0/spree-3233ae973a97/frontend/app/views/spree/products/index.html.erb within spree/layouts/spree_application (949.6ms)
Completed 500 Internal Server Error in 1660ms

ActionView::Template::Error (undefined method `[]' for true:TrueClass):
     8:         <%= link_to small_image(product, :itemprop => "image"), product, :itemprop => 'url' %>
     9: </div>
    10:       <%= link_to truncate(product.name, :length => 50), product, :class => 'info', :itemprop => "name", :title => product.name %><span class="price selling" itemprop="price"><%= display_price(product) %></span><div class="quick-add-to-cart-form">
    11:   <% order = current_order(true) %><span class="current-order-path" style="display:none">
    12:     <%= api_current_order_path %></span>
    13:   <%= form_tag api_order_line_items_path(order.number), method: :post do %><div class="fields">
    14:     <%= hidden_field_tag "order_token", order.token %><%= hidden_field_tag "line_item[variant_id]", product.master.id %><%= number_field_tag "line_item[quantity]", 1, :class => 'add-quantity', :min => 1 %><%= button_tag :class => 'large primary add-button', :type => :submit do %><%= Spree.t(:add_to_cart) %><% end %>
  /Users/Oli/.bundler/ruby/2.0.0/spree-3233ae973a97/core/lib/spree/core/controller_helpers/order.rb:15:in `current_order'
  actionpack (4.0.2) lib/abstract_controller/helpers.rb:53:in `current_order'
  /Users/Oli/.bundler/ruby/2.0.0/spree-3233ae973a97/frontend/app/views/spree/shared/_products.html.erb:11:in `block in _8b688e754dd28673149759b6624658cd'
  activerecord (4.0.2) lib/active_record/relation/delegation.rb:13:in `each'
  activerecord (4.0.2) lib/active_record/relation/delegation.rb:13:in `each'

And gemfile is:

source 'https://rubygems.org'

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.0.2'

# Use sqlite3 as the database for Active Record
gem 'sqlite3'

# Use SCSS for stylesheets
gem 'sass-rails', '~> 4.0.0'

# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'

# Use CoffeeScript for .js.coffee assets and views
gem 'coffee-rails', '~> 4.0.0'

# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby

# Use jquery as the JavaScript library
gem 'jquery-rails'

# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'

# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 1.2'

group :doc do
  # bundle exec rake doc:rails generates the API under doc/api.
  gem 'sdoc', require: false
end

# Use ActiveModel has_secure_password
# gem 'bcrypt-ruby', '~> 3.1.2'

# Use unicorn as the app server
# gem 'unicorn'

# Use Capistrano for deployment
# gem 'capistrano', group: :development

# Use debugger
# gem 'debugger', group: [:development, :test]

gem 'spree', github: 'spree/spree', branch: '2-1-stable'
gem 'spree_auth_devise', github: 'spree/spree_auth_devise', branch: '2-1-stable'
gem 'spree_yoyo_theme', :path => '../spree_yoyo_theme'
gem 'spree_static_content', :github => 'spree/spree_static_content', branch: '2-1-stable'
gem 'spree_address_book', :github => 'romul/spree_address_book', branch:'2-1-stable'
gem 'spree_paypal_express', :github => 'radar/better_spree_paypal_express', branch: '2-1-stable'
gem 'spree_reviews', github: 'spree/spree_reviews', branch: '2-1-stable'
gem 'spree_recently_viewed', github: 'spree/spree_recently_viewed', branch: '2-1-stable'
gem 'spree_loyalty_points', github: 'vinsol/spree-loyalty-points'
gem "spree_comments", github: 'spree/spree_comments', branch:'2-1-stable'

gem 'rabl'
gem 'haml'
gem 'spree_quick_cart'

Thanks for the help

Oli

@tiagoamaro
Copy link

I had this same problem. This is because spree 2-1-stable branch changed the current_order helper implementation to accept an opitons hash.

Check these lines: https://github.com/spree/spree/blob/2-1-stable/core/lib/spree/core/controller_helpers/order.rb#L14-L15

Quick solution: just remove the true on the <% order = current_order(true) %>.

It will be: <% order = current_order %>

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants