Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9011491
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T02:44:48+00:00 2026-06-16T02:44:48+00:00

I’m tying to perform an edit action on one of my nested models. I

  • 0

I’m tying to perform an edit action on one of my nested models. I keep getting the following error “undefined method `model_name’ for NilClass:Class”

I don’t know what’s going on. Any help?

Routes

  resources :users, :except => [ :create, :new ] do
     resources :store do
       get "inbox", :on => :collection
       get "openedmessages", :on => :collection
     end
  end

Store Actions

  def edit
    @store = current_user.store.id
  end

  def create
    @store = current_user.store.new(params[:store])
  end

  def update
    @stores = current_user.store.id
    if @stores.update_attributes
      flash[:success] = "Store has been updated"
      render 'edit'
    else
      render 'edit'
    end
  end

View for Edit Action in Store

<ul class="storedashboard_header">
    <li><%= link_to "Manage Gear", user_store_index_path(current_user) %></li>
    <li><%= link_to "Store Appearance", edit_user_store_path(current_user, @store) %></li>
    <li><%= link_to "Announcements", '#' %></li>
</ul>
    <%= render "users/userdashboard_header" %>
    <%= render "store/storemenu" %>
    <div style="clear:both"></div>
    <% flash.each do |name, msg| %>
      <div class="alert alert-success">
        <a class="close" data-dismiss="alert">×</a>
        <%= msg %>
      </div>
    <% end %>
    <div>
        <%= simple_form_for @stores, :html => {:multipart => true, :class => 'form-horizontal'} do |f| %>
            </br>
            <div style="float: left;">
            <%= f.input :storename %>
            <%= f.input :storeimage %>
            <%= f.input :storelogo %>
            <%= f.button :submit, class: 'btn btn-large', style: 'margin-left: 40px;'  %>
            </div>
        <% end %>
    </div>

UPDATED

Changed my Controller to the following:

  def edit
    @store = Store.find(current_user.store.id)
  end

  def create
    @store = current_user.store.new(params[:store])
  end

  def update
    @store = Store.find(current_user.store.id)
    if @store.update_attributes(params[:store])
      flash[:success] = "Store has been updated"
      render 'edit'
    else
      render 'edit'
    end
  end

New Error after Update

undefined method `store_path’ for #<#:0x007fec93b97238>

FINAL FIX

Needed to fix the view…

    <%= simple_form_for [current_user, @store], :html => {:multipart => true, :class => 'form-horizontal'} do |f| %>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T02:44:49+00:00Added an answer on June 16, 2026 at 2:44 am

    if i understand your question properly:

    @store needs to be an object for the model Store instead of just the id.

    something like:
    @store = Store.find(current_user.store.id) will return the object

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I'm making a simple page using Google Maps API 3. My first. One marker
Let's say I'm outputting a post title and in our database, it's Hello Y&#8217;all
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.