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

  • Home
  • SEARCH
  • 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 6646673
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T00:26:43+00:00 2026-05-26T00:26:43+00:00

How do i access store name here?@deal instance can access perfectly item name,but when

  • 0

How do i access store name here?@deal instance can access perfectly item name,but when i try to access store name it gives me

no method error 'stores'

How do i get store instance to access store name?Here is the code.Thank you in advance

controller

def show
   unless session[:city_id].nil? || session[:city_id].blank?
   @city = City.find(session[:city_id])
   @deal=@city.deals
   @store=@deal.stores
end

view/show

<% @deal.each do |deal| %>
<%=deal.item_name %>
<%end%>

<%=@store.store_name %>

models

class Store < ActiveRecord::Base
    has_many :deals ,:through =>:store_deals
    has_many :store_deals
end

class Deal < ActiveRecord::Base
    has_many :stores ,:through =>:store_deals
    has_many :store_deals
end

class StoreDeal < ActiveRecord::Base
    belongs_to :store
    belongs_to :deal
end
  • 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-05-26T00:26:44+00:00Added an answer on May 26, 2026 at 12:26 am

    @deal is most likely an array of deals. @city.deals implies you could have multiple deals per city. This wil cause a problem when you try to do

    @deal=@city.deals
    @store=@deal.stores
    

    try something like:

    @deals = @city.deals
    @stores = @deals.collect(&:stores)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know you can access the Contact Store from the SDk, but is it
I need to store a file, such that my ASP.Net MVC app can access
How do I implement error handling elegantly? For example, my data access layer can
How can I store a value within Selenium-RC (through PHPUnit) and then retrieve/access it
How can I store/access global variables within a monotouch application? I am retrieving the
I need to store some simple properties in a file and access them from
I have an versioned document store which I want to access through an dict
Is there any easy way to access the SVN repository revision number and store
I want to access an image stored in Blackberry, say at location store/home/user/image.png .
I am trying to access a stored procedure and I'm getting an error that

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.