All threads / undefined method `minimum' for #<Store:0x00007fb25c749b20>
Ask A Question


You’re not receiving notifications from this thread.

undefined method `minimum' for #<Store:0x00007fb25c749b20>

Samantha O asked in General

I have a Store model and a PricingClassification model. The PricingClassification belongs to Store. I have made a wizard for creating a store and I am trying to add a range in pricingClassification. But I get the undefined method `minimum' for #Store:0x00007fb25c749b20
What am I missing or doing wrong?

class Store < ApplicationRecord
  has_many :pricing_classifications, dependent: :destroy

class PricingClassification < ApplicationRecord
  belongs_to :store

module PricingClassificationsHelper
      def range_string(pricing_classification)

While creating a new store I have this in my view.
<%= f.label :pricing_classification %>
<%= select_tag nil, options_for_select(range_options, range_string(f.object)) %>
<%= f.hidden_field :minimum %>
<%= f.hidden_field :maximum %>

It works!
I had to add a form_for block in the view and pass the pricingclassification object.

<%= form_for :pricing_classification do |f| %>
        <%= f.label :pricing_classification %>
        <%= select_tag nil, options_for_select(range_options, range_string(, data: { action: "change->range#change" } %>
        <%= f.hidden_field :minimum, data: { target: "range.minimum" } %>
        <%= f.hidden_field :maximum, data: { target: "range.maximum" } %>
        <% end %>
Join the discussion

Want to stay up-to-date with Ruby on Rails?

Join 66,029+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.

    logo Created with Sketch.

    Screencast tutorials to help you learn Ruby on Rails, Javascript, Hotwire, Turbo, Stimulus.js, PostgreSQL, MySQL, Ubuntu, and more. Icons by Icons8

    © 2022 GoRails, LLC. All rights reserved.