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 9213491
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T01:45:44+00:00 2026-06-18T01:45:44+00:00

I’ve been tinkering with this for some time now, and can’t seem to figure

  • 0

I’ve been tinkering with this for some time now, and can’t seem to figure this out. It’s probably something simple, but here goes:

I have a has_many :trough relationship between ‘laminate’, and ‘standards’ with a joined model ‘standardization’.

Standard.rb

class Standard < ActiveRecord::Base
attr_accessible :description, :name
has_many :standardizations
has_many :laminates, :through => :standardizations
end

Standardization.rb

class Standardization < ActiveRecord::Base
  attr_accessible :laminate_id, :standard_id
  belongs_to :laminate
  belongs_to :standard
end

Laminate.rb

class Laminate < ActiveRecord::Base
attr_accessible :name, :standard_ids
has_many :standardizations
has_many :standards, :through => :standardizations
end

The scenario is that laminates can belong to several standards, and I’ve got everything working in the new-part of the view – checkboxes and everything. My problem is when trying to display the names of the corresponding standards for a given laminate. As of now I’m able to display which standards the laminates are assigned to, but not ONLY the names of the standards.

My show.html.erb says:

<%= @laminate.standards %>

And this returns everything correct, but saying

 <%= @laminate.standards.name %>

… does not work. How on earth can I tap into the names of each individual, assigned standard?

Laminate_controller:

class LaminatesController < ApplicationController
# GET /laminates
# GET /laminates.json
def index
@laminates = Laminate.all
@standards = Standard.all

respond_to do |format|
  format.html # index.html.erb
  format.json { render json: @laminates }
end
end

# GET /laminates/1
# GET /laminates/1.json
def show
@laminate = Laminate.find(params[:id])
@standard = Standard.find(params[:id])

respond_to do |format|
  format.html # show.html.erb
  format.json { render json: @laminate }
end
end

# GET /laminates/new
# GET /laminates/new.json
def new
@laminate = Laminate.new


respond_to do |format|
  format.html # new.html.erb
  format.json { render json: @laminate }
end
end

# GET /laminates/1/edit
def edit
@laminate = Laminate.find(params[:id])
end

# POST /laminates
# POST /laminates.json
def create
@laminate = Laminate.new(params[:laminate])

respond_to do |format|
  if @laminate.save
    format.html { redirect_to @laminate, notice: 'Laminate was successfully created.' }
    format.json { render json: @laminate, status: :created, location: @laminate }
  else
    format.html { render action: "new" }
    format.json { render json: @laminate.errors, status: :unprocessable_entity }
  end
  end
end

# PUT /laminates/1
# PUT /laminates/1.json
def update
@laminate = Laminate.find(params[:id])

respond_to do |format|
  if @laminate.update_attributes(params[:laminate])
    format.html { redirect_to @laminate, notice: 'Laminate was successfully updated.' }
    format.json { head :no_content }
  else
    format.html { render action: "edit" }
    format.json { render json: @laminate.errors, status: :unprocessable_entity }
  end
 end
end

# DELETE /laminates/1
# DELETE /laminates/1.json
def destroy
@laminate = Laminate.find(params[:id])
@laminate.destroy

respond_to do |format|
  format.html { redirect_to laminates_url }
  format.json { head :no_content }
  end
 end
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-06-18T01:45:45+00:00Added an answer on June 18, 2026 at 1:45 am

    The following @laminate.standards return a list of Standards. Call name here can’t work, you should do a each loop on the list:

    # replace the following:
    <%= @laminate.standards.name %>
    # with this code:
    <% @laminate.standards.each do |standard| %>
      <%= standard.name %>
    <% end %>
    

    If you want a shorter version but less customizable:

    <%= @laminate.standards.map{ |standard| standard.name }.join(', ') %>
    # This will show all the standards' name with a coma-space ',' between it
    
    # same a above but shorter:
    <%= @laminate.standards.map(&:name).join(', ') %>
    # this will call the 'name' method on each standard of @laminate.standards
    # and join them with a coma-space
    # something that would look like this:
    # name1, name2, name3
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a jquery bug and I've been looking for hours now, I can't
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,
This could be a duplicate question, but I have no idea what search terms
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I know there's a lot of other questions out there that deal with this
Does anyone know how can I replace this 2 symbol below from the string
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
Seemingly simple, but I cannot find anything relevant on the web. What is the

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.