| 2011-07-02 10:13:55 utc | caral | hi |
| 2011-07-02 10:15:00 utc | jmettraux | caral: hi, welcome to #ruote |
| 2011-07-02 10:16:28 utc | caral | thx, i'm using the rufus scheduler and have a question about it, but first I search through the topics ;) |
| 2011-07-02 10:53:25 utc | caral | I like to update a Model in my rails app frequently with the rufus scheduler, that works. But if I include the normal Rails Observer i get an Error "scheduler caught exception : Expected model.rb to define Model". Is it possible to observe what the scheduler does with the model? Maybe its a conceptual false idea? |
| 2011-07-02 10:54:35 utc | jmettraux | yes, it's easy |
| 2011-07-02 10:54:49 utc | jmettraux | use print, puts, pp, or p |
| 2011-07-02 10:55:09 utc | jmettraux | or ap |
| 2011-07-02 10:55:50 utc | jmettraux | Expected model.rb to define Model, Rails is complaining that your file model.rb doesn't contain "class Model" or "module Model" |
| 2011-07-02 10:57:06 utc | caral | I c&p the files to a pastie just a second (or two ) |
| 2011-07-02 10:57:34 utc | jmettraux | I have to warn you, my Rails knowledege is very limited |
| 2011-07-02 10:59:46 utc | jmettraux | s/knowledege/knowledge/ |
| 2011-07-02 11:13:39 utc | caral | a little pasti to illustrate my problem http://pastebin.com/SwuwYHnq |
| 2011-07-02 11:14:42 utc | jmettraux | caral : what is the full path to your news.rb file ? |
| 2011-07-02 11:14:57 utc | jmettraux | "Expected /rails/sampleapp/app/models/news.rb to define News" |
| 2011-07-02 11:15:35 utc | caral | the path is correct, its the normal rails path in the models directory |
| 2011-07-02 11:16:51 utc | jmettraux | where do you place news_observer.rb ? |
| 2011-07-02 11:16:55 utc | jmettraux | which version of Rails ? |
| 2011-07-02 11:17:04 utc | jmettraux | ah 3.0.5 |
| 2011-07-02 11:17:10 utc | caral | in the same directory with the model |
| 2011-07-02 11:18:54 utc | caral | like here suggested http://apidock.com/rails/ActiveRecord/Observer |
| 2011-07-02 11:20:27 utc | jmettraux | ok, googling the rails documentation |
| 2011-07-02 11:21:46 utc | jmettraux | caral: if you fire up your rails console and type "News" + Enter what happens ? |
| 2011-07-02 11:23:29 utc | jmettraux | caral: if you do "find . -name news.rb" from your rails root, what does it yield ? |
| 2011-07-02 11:23:47 utc | caral | the normal, return value is the class, it is found in the console |
| 2011-07-02 11:24:52 utc | caral | "./app/models/news.rb" like expected |
| 2011-07-02 11:25:48 utc | jmettraux | sorry, but I can't determine that by myself, I have to ask you |
| 2011-07-02 11:26:19 utc | jmettraux | what server are you using ? |
| 2011-07-02 11:26:46 utc | caral | WEBrick 1.3.1 |
| 2011-07-02 11:28:04 utc | jmettraux | may I have the complete snip ? |
| 2011-07-02 11:28:26 utc | caral | i think it must have something to do with Namespaces, but my knowlege is limited :( |
| 2011-07-02 11:28:52 utc | caral | the error message? |
| 2011-07-02 11:28:57 utc | jmettraux | yes |
| 2011-07-02 11:29:02 utc | caral | sure |
| 2011-07-02 11:30:19 utc | jmettraux | if you add a "require File.expand_path(File.join(File.dirname(__FILE__), 'news.rb'))" on top of your news_observer.rb, what happens ? |
| 2011-07-02 11:31:00 utc | jmettraux | other variant : if you change from "News" to "Information", what happens ? Maybe Rails has trouble with an already pluralized class name |
| 2011-07-02 11:31:54 utc | caral | second could I exclude, there should be no problem with that. |
| 2011-07-02 11:32:14 utc | jmettraux | caral: trusting is good, checking is better |
| 2011-07-02 11:33:28 utc | caral | indeed |
| 2011-07-02 11:33:42 utc | caral | here is the full error log http://pastebin.com/pZ5R7Uni |
| 2011-07-02 11:34:40 utc | jmettraux | thanks |
| 2011-07-02 11:37:43 utc | jmettraux | the "const missing" comes from rake, what happens if you remove the "require 'rake'" from task_scheduler.rb ? |
| 2011-07-02 11:41:04 utc | caral | omg, it seems to work. :D the "require File.expand_path(File.join(File.dirname(__FILE__), 'news.rb'))" does the trick. |
| 2011-07-02 11:41:20 utc | caral | you are a master *thumbsveryup* |
| 2011-07-02 11:41:46 utc | jmettraux | it's a super ugly workaround, Rails is supposed to take care of the requires for you |
| 2011-07-02 11:42:06 utc | jmettraux | I wonder what happens if you remove the "require 'rake'" |
| 2011-07-02 11:42:26 utc | caral | nothing happen then I tried this also |
| 2011-07-02 11:42:36 utc | jmettraux | no error ? |
| 2011-07-02 11:42:57 utc | caral | no changein the error message |
| 2011-07-02 11:43:01 utc | caral | *change in |
| 2011-07-02 11:43:06 utc | jmettraux | ah ok |
| 2011-07-02 11:43:49 utc | caral | in a step ago I tried to update the model with a rake task inside the scheduler, now the work is done in a class method of news |
| 2011-07-02 11:43:56 utc | jmettraux | ok |
| 2011-07-02 11:44:10 utc | jmettraux | I wonder how your code works in Rails 3.0.9 |
| 2011-07-02 11:44:17 utc | jmettraux | maybe the issue is solved there |
| 2011-07-02 11:46:44 utc | caral | thats a good question, I try this out another time, first I have to google for update rails on mac etc. I almost forgotten this ;) |
| 2011-07-02 11:46:58 utc | caral | I have to say: Thank you for your help! |
| 2011-07-02 11:47:05 utc | jmettraux | you should use bundler |
| 2011-07-02 11:47:27 utc | jmettraux | the upgrade would be limited to changing one line in your Gemfile and running "bundle update rails" |
| 2011-07-02 11:48:23 utc | caral | i try this out |
| 2011-07-02 11:49:19 utc | jmettraux | and RVM is a must too, it can really simplify your life |
| 2011-07-02 11:56:21 utc | jmettraux | you're welcome, I have to go, have a nice day/evening/night ! |