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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T17:46:29+00:00 2026-05-27T17:46:29+00:00

i am getting this undefined method for albums controller and model any solutions?… undefined

  • 0

i am getting this undefined method for albums controller and model any solutions?…

undefined method `model_name’ for ActiveRecord::Relation:Class

Extracted source (around line #6):

3: >>

4: new album

5:

6: = form_for @albums do |f|

7: = f.error_messages

8: %p

9: = f.label :name


   =link_to 'albums', albums_path
      >>
      new album
    = form_for @album do |f|
      = f.error_messages
  %p
    = f.label :name
    = f.text_field :name

  %p
    = f.label :description
    = f.text_field :description, :rows => 3
  %p
    = f.submit

%p= link_to "Back to List", albums_path

   class AlbumsController < ApplicationController
  before_filter :authenticate_user!

  respond_to :html
  respond_to :json

  def index
    @albums = current_user.albums.paginate :page => params[:page], :per_page => 9, :order => 'created_at DESC'
    respond_with @albums, :aspect => @aspect
  end

  def create
    aspect = params[:album][:to]

    @album = current_user.post(:album, params[:album])
    if @album.persisted?
      redirect_to :action => :show, :id => @album.id, :aspect => aspect
    else
      redirect_to albums_path(:aspect => aspect)
    end
  end

  def new
    @album = Album.new
  end

  def destroy
    @album = current_user.find_visible_post_by_id params[:id]
    @album.destroy
    respond_with :location => albums_url
  end

  def show
    @person = current_user.visible_people.find_by_person_id(params[:person_id]) if params[:person_id]
    @person ||= current_user.person

    @album = :uploads if params[:id] == "uploads"
    @album ||= current_user.find_visible_post_by_id(params[:id])

    unless @album
      render :file => "#{Rails.root}/public/404.html", :layout => false, :status => 404
    else

      if @album == :uploads
        @album_id = nil
        @album_name = "Uploads"
        @album_photos = current_user.visible_posts(:_type => "Photo", :album_id => nil, :person_id => @person.id)

      else
        @album_id = @album.id
        @album_name = @album.name
        @album_photos = @album.photos
      end

      respond_with @album
    end
  end

  def edit
    @album = current_user.find_visible_post_by_id params[:id]
    redirect_to @album unless current_user.owns? @album
  end

  def update
    @album = current_user.find_visible_post_by_id params[:id]

    if current_user.update_post( @album, params[:album] )
      respond_with @album
    else
      render :action => :edit
    end
  end

end

class Album < ActiveRecord::Base
  include ROXML
  xml_attr :name
  xml_attr :description

  belongs_to :user
  belongs_to :person
  validates :person, :presence => true

  has_many :photos, :class_name => 'Photo', :foreign_key => :album_id

  validates_presence_of :name
  validates :person, :presence => true



     before_destroy :destroy_photos

      attr_accessible :name
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-27T17:46:29+00:00Added an answer on May 27, 2026 at 5:46 pm
    =form_for @albums do |f|
    

    Should be

    =form_for @album do |f|
    

    @album vs @albums, just guessing here based on your error message, in your code example it looks correct, not sure how they could differ? The error is from the new action?

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

Sidebar

Related Questions

I'm getting this error: undefined method `post_comments_path' for #<#<Class:0x1052a6e98>:0x1052a4be8> Extracted source (around line #27):
I'm getting this strange error using Rails 3.0.2. ActionView::Template::Error (undefined method `parent' for nil:NilClass):
Can someone tell me why I am getting this error? Call to undefined method
I don't know when it happened but I'm getting this error NoMethodError (undefined method
I am getting this error while following the tutorial from railstutorial.org. Model class :
I've been getting this undefined symbol building with this command line: $ gcc test.cpp
Trying to compile a iPhone/iPad application with SDK3.2 and am getting this error: Undefined
I have this code and I keep getting undefined if I test the selectedIndex.
I keep getting an Notice: Undefined index: did error with this query, and I'm
does anyone know why im getting this error? 'PHP Fatal error: Call to undefined

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.