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 ............ Cccweb::Application.routes.draw do resources :captionfiles resources :runs get "pages/choose" get "home/index" get "runs/new" root :to => ''home#index'' end ................. I''ve searched the internets as well as many message bases, and although I come up with variants of this message, none of the solutions seem to help. Thank you! -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 9 March 2012 19:52, AndyLikesRuby <usbdish-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 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 > endCan 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org 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.
On 9 March 2012 19:52, AndyLikesRuby <usbdish-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> 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'' > > @captionfiles = Captionfile.all > > class Captionfile < ActiveRecord::BaseThere''s nothing, at first glance, wrong with your code. So can you just confirm which version of Rails you have installed. Older (very old!) versions didn''t have ".all", you had to use ".find(:all)". But if that''s your problem, you must be on Rails 1.x, and that won''t be the last of your problems... -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org 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.
Does it work when you run Captionfile.all in your rails console? On Friday, March 9, 2012 11:52:34 AM UTC-8, AndyLikesRuby 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 > ............ > > Cccweb::Application.routes.draw do > resources :captionfiles > resources :runs > get "pages/choose" > get "home/index" > get "runs/new" > root :to => ''home#index'' > end > ................. > > I''ve searched the internets as well as many message bases, and > although I come up with variants of this message, none of the > solutions seem to help. > > Thank you!-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/yNx82A1h-GYJ. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Hi Michael -- I am using Ruby v1.9.2p290, Rails v3.2.2, and rvm 1.8.5. I checked to see if I had duplicate files, but to no avail. I will do some deep digging this morning. If I find a solution, I''ll post it. Thanks for your help. Andy On Mar 12, 12:17 am, Michael Pavling <pavl...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On 9 March 2012 19:52, AndyLikesRuby <usbd...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > 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'' > > > @captionfiles = Captionfile.all > > > class Captionfile < ActiveRecord::Base > > There''s nothing, at first glance, wrong with your code. So can you > just confirm which version of Rails you have installed. Older (very > old!) versions didn''t have ".all", you had to use ".find(:all)". But > if that''s your problem, you must be on Rails 1.x, and that won''t be > the last of your problems...-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org 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.
Hi Colin, I did try restarting the server, etc. I still can''t fix the problem. I am going to do some deep-diving into the code today. I suspect it has something to do with a file like routes.db, or similar. The code seems to be ok -- there''s something else that isn''t quite evident that''s causing this issue. Thanks for your help! Andy On Mar 11, 2:49 pm, Colin Law <clan...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> On 9 March 2012 19:52, AndyLikesRuby <usbd...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org 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.
On 13 March 2012 17:36, AndyLikesRuby <usbdish-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi Colin, > > I did try restarting the server, etc. I still can''t fix the problem.You did not say whether you can do anything useful with the class at all (probably because you top posted rather than inserting comments inline). This would have told us whether it is something specific to do with #all or whether your class is not being recognised as an ActiveRecord class. Colin> > I am going to do some deep-diving into the code today. I suspect it > has something to do with a file like routes.db, or similar. The code > seems to be ok -- there''s something else that isn''t quite evident > that''s causing this issue. > > Thanks for your help! > > Andy > > On Mar 11, 2:49 pm, Colin Law <clan...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote: >> On 9 March 2012 19:52, AndyLikesRuby <usbd...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > 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. >-- gplus.to/clanlaw -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org 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.
Hi Colin, Thanks for the reply. Your question prompted me to search around my class declarations, and sure enough, I found the problem. I declared two container classes, Captionfile and Run, to capture information in a convenient, encapsulated format. From there I create objects to make arrays/hashes for processing I stored them in the /lib directory, which apparently conflicted with the ActiveRecord class declarations of the same name. I renamed the class files and suddenly it all worked. I now have to figure out how to include these class files without conflict (I''ll likely rename them). Thanks for your tipoff! That''s what lead me to my solution. Cheers, Andy On Mar 13, 10:58 am, Colin Law <clan...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> On 13 March 2012 17:36, AndyLikesRuby <usbd...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > Hi Colin, > > > I did try restarting the server, etc. I still can''t fix the problem. > > You did not say whether you can do anything useful with the class at > all (probably because you top posted rather than inserting comments > inline). This would have told us whether it is something specific to > do with #all or whether your class is not being recognised as an > ActiveRecord class. > > Colin > > > > > > > > > > > > > I am going to do some deep-diving into the code today. I suspect it > > has something to do with a file like routes.db, or similar. The code > > seems to be ok -- there''s something else that isn''t quite evident > > that''s causing this issue. > > > Thanks for your help! > > > Andy > > > On Mar 11, 2:49 pm, Colin Law <clan...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote: > >> On 9 March 2012 19:52, AndyLikesRuby <usbd...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > > For more options, visit this group athttp://groups.google.com/group/rubyonrails-talk?hl=en. > > -- > gplus.to/clanlaw-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org 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.
On 13 March 2012 21:55, AndyLikesRuby <usbdish-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi Colin, > > Thanks for the reply. Your question prompted me to search around my > class declarations, and sure enough, I found the problem. > > I declared two container classes, Captionfile and Run, to capture > information in a convenient, encapsulated format. From there I create > objects to make arrays/hashes for processing > > I stored them in the /lib directory, which apparently conflicted with > the ActiveRecord class declarations of the same name.That is why I suggested doing a global search for Captionfile.> > I renamed the class files and suddenly it all worked. I now have to > figure out how to include these class files without conflict (I''ll > likely rename them).You can''t have two different classes of the same name.> > Thanks for your tipoff! That''s what lead me to my solution.Glad to be of help 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org 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.