Kevin, Thank you so much. It works! Ephraim On Friday, August 16, 2013 12:22:55 PM UTC-7, Ephraim Feig wrote: > > I have numerous paginations in my application; they all look alike; all > but one work fine. The one broken one breaks at the very last step. The > details are below. I have 3 classes- Micropost, Category, Selection. I > have a link that points to details_controller, which renders a view > /selections/detailslist which in turn renders the partial > /selections/details. The code successfully gets to the last view and breaks > in the third line, with the error message "undefined local variable or > method `micropost' for #<#<Class: ...." Any help here would be greatly > appreciated. > > class Micropost < ActiveRecord::Base > attr_accessible :content, :category_content, :selection_content, > :category_id, :selection_id, :user_id > > belongs_to :user > belongs_to :category > belongs_to :selection > validates :user_id, presence: true > validates :category_content, presence: true > validates :selection_content, presence: true > end > > > class Category < ActiveRecord::Base > attr_accessible :content, :id, :count, :c_count > has_many :selections > has_many :microposts > end > > class Selection < ActiveRecord::Base > attr_accessible :content, :count, :category_id > belongs_to :category > has_many :microposts > end > > ****** view with link ***** > <li> > <span class="selection"> > <%= selection.content %> >     > ( <%= selection.count %> ) >     > <%= link_to "Details", controller: :details, param1: selection.id, > param2: selection.category_id %> > </span> > </li> > > ****** details_controller*********** > class DetailsController < ApplicationController > require 'will_paginate/array' > respond_to :html, :js > > def index > #@category = Category.find_by_id(params[:param2]) > @selection = Selection.find_by_id(params[:param1]) > @microposts = @selection.microposts.paginate(page: params[:page]) > render '/selections/detailslist' > end > end > > ******* view /selections/detailslist********** > <% @category = Category.find_by_id(@selection.category_id) %> > <h3> <%= @category.content %> </h3> > <br> > <%= @selection.content %> >   > ( <%= @selection.count %> ) > <br> > <ol class="selections"> > <%= render partial: 'selections/details', collection: @microposts %> > </ol> > <%= will_paginate @microposts %> > > > *****view selections/details ************* > <li> > <span class="selection"> > <% user = User.find_by_id(micropost.user_id) %> > <%= user.name %> > </span> > </li> > > > ****** error message ********* > undefined local variable or method `micropost' for #<#<Class: >
-- -- SD Ruby mailing list [email protected] http://groups.google.com/group/sdruby --- You received this message because you are subscribed to the Google Groups "SD Ruby" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/groups/opt_out.
