Is it possible to access models when your in the console ? It seems
like that is not possible and I need to create the classes within the
console. Am I doing something wrong ?
Stuart
Is it possible to access models when your in the console ? It seems
like that is not possible and I need to create the classes within the
console. Am I doing something wrong ?
Stuart
After posting this question I went ahead and did some googling so I
found the parameters
NAME and DESCRIPTION but found I’m getting these errors:
C:\InstantRails\rails_apps\r4rmusic>ruby script/console NAME
Loading NAME environment.
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/rails-1.1.4/lib/initializer.rb:168:in
`read’:Errno::ENOENT: No such file or
directory - ./script/…/config/…/config/…/config/environments/NAME.rb
C:\InstantRails\rails_apps\r4rmusic>ruby script/console DESCRIPTION
Loading DESCRIPTION environment.
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/rails-1.1.4/lib/initializer.rb:168:in
`read’:Errno::ENOENT: No such file or
directory -
./script/…/config/…/config/…/config/environments/DESCRIPTION.rb
So now that I think I know how to access the models and controllers
from console, I seem to have a problem.
Any ideas ?
Stuart
On Aug 13, 2006, at 11:35 AM, Dark A. wrote:
Is it possible to access models when your in the console ? It seems
like that is not possible and I need to create the classes within the
console. Am I doing something wrong ?Stuart
Rails mailing list
[email protected]
http://lists.rubyonrails.org/mailman/listinfo/rails
Yes its possible. Actually thats pretty much the main point of
script/console. In order to tell it what env you want to run in try
this:
$ script/console production
OR
$ script/console test
OR
$ script/console # this one will default to development env.
Then your models are just available in the console. Am I missing
something about your problem?
-Ezra
On Mon, 2006-08-14 at 07:54 -0600, Dark A. wrote:
class User
end
now i can add a new user . However the same goes for any methods that
maybe defined within that model. Those also seem to need to be
recreated in the console.My assumption was that when entering console all controllers and
models (including the methods withing) would be immediately available.
So what am I doing wrong ?
$ script/console
require “app/models/user.rb”
Craig
My problem is that it seems within console the models are not
available immediately.
As an example I have a model name user.rb. Table is set up
accordingly. I’m connected to the database.
I open console and do:
abe = User.new
This won’t work as User is not recognized.
I’m forced to define the class again in the console.
class User
end
now i can add a new user . However the same goes for any methods that
maybe defined within that model. Those also seem to need to be
recreated in the console.
My assumption was that when entering console all controllers and
models (including the methods withing) would be immediately available.
So what am I doing wrong ?
Stuart
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs