Sunday, March 11, 2012

Re: [Rails] NoMethodError

On 9 March 2012 19:52, AndyLikesRuby <usbdish@gmail.com> wrote:
> Hello fellow Ruby enthusiasts!
>
> Although I've been using Ruby for some time, I just started using
> RoR.  I'm experiencing an error that I'm having trouble resolving and
> was hoping to find some help.
>
> I am getting this error message when I try to hit a certain URL:
>
> http://localhost:3000/captionfiles
>
> NoMethodError in CaptionfilesController#index
> undefined method `all' for Captionfile:Class
> app/controllers/captionfiles_controller.rb:5:in `index'
>
> Here are my files:
>
> class CaptionfilesController < ApplicationController
>  def index
>    @captionfiles = Captionfile.all
>
>    respond_to do |format|
>      format.html # index.html.erb
>      format.json { render json: @captionfiles }
>    end
>  end
> .............
> class Captionfile < ActiveRecord::Base
>  validates :title, :presence => true, :length => { :minimum => 2 }
>  validates :filename, :presence => true
>  has_many :run
> end

Can you do anything useful with the Captionfile class? Creating
records for example.

I assume you have you tried restarting the server.

Are you sure you have not got Captionfile declared in another file
somewhere? Perhaps you kept a copy of captionfiles.rb with an out of
date definition in it. Do a global source search for Captionfile in
your project.

That should be has_many :runs by the way (plural) but I don't think
that is anything to do with this problem.

Colin

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate