Rails Console Isn't functioning the same as running in terminal

I am looking at RoR and so I have been evaluating the latest RubyMine (4.5) IDE.

Ok, I am new to RoR so please bear with me if the reason this is something due to my noobieness, but it seems that running Rails C in a terminal window behaves very differently than from inside the IDE.

Inside Terminal, simple little operation here:

Loading development environment (Rails 3.2.8)
1.9.3p194 :001 > subject = Subject.new
=> #<Subject id: nil, name: nil, position: nil, visible: false, created_at: nil, updated_at: nil>
1.9.3p194 :002 > subjects = Subject.all
  Subject Load (0.4ms)  SELECT `subjects`.* FROM `subjects`
=> [#<Subject id: 1, name: "First Subject", position: 1, visible: true, created_at: "2012-09-10 04:18:02", updated_at: "2012-09-10 04:18:02">, #<Subject id: 2, name: "Second Subject", position: 2, visible: false, created_at: "2012-09-10 04:20:47", updated_at: "2012-09-10 04:20:47">, #<Subject id: 4, name: "Third Subject", position: 3, visible: false, created_at: "2012-09-10 04:54:51", updated_at: "2012-09-10 04:54:51">]
1.9.3p194 :003 > subjects.each do |subject|
1.9.3p194 :004 >     puts subject.name
1.9.3p194 :005?>   end
First Subject
Second Subject
Third Subject
=> [#<Subject id: 1, name: "First Subject", position: 1, visible: true, created_at: "2012-09-10 04:18:02", updated_at: "2012-09-10 04:18:02">, #<Subject id: 2, name: "Second Subject", position: 2, visible: false, created_at: "2012-09-10 04:20:47", updated_at: "2012-09-10 04:20:47">, #<Subject id: 4, name: "Third Subject", position: 3, visible: false, created_at: "2012-09-10 04:54:51", updated_at: "2012-09-10 04:54:51">]
1.9.3p194 :006 > exit

Ok, this is what I would expect.  Simple stuff for sure.

Now, from inside the IDE, trying to do the same thing:

As soon as I hit the return for the next line, I get a prompt as though the previous was completed already:

RailsConsole-1.png

Coming from mostly a PHP background, I'm liking RoR so far.  I hope this is just a noobie mistake.

Thanks in advance for assistance on this.

-John

7 comments
Comment actions Permalink

Hi John,

as far as I understand you expect different prompt when you are in the middle of multi-line expression.
Prompt change is not implemented in RM for now.
If you believe that this is important feature feel free to file a feature request in our tracker (youtrack.jetbrains.com/issues/ruby)

Regards, Oleg.

0
Comment actions Permalink

Oleg,

It doesn't work if I put the whole set of commands on one line either.  Should it?

As I learn about other type of queries, some of them fail also.

It would be really help ful if the IDE could run consoles as though they were terminal.

So, I was reading that to run terminal inside the IDE might be possible also.  Is this correct?

I was reading the docs and it's not clear to me, (not yet :)) if this is possible and how I would do that.

Thank you for your help,

-John

0
Comment actions Permalink

Hi John,

> It doesn't work if I put the whole set of commands on one line either.  Should it?

I'm not sure what do you mean here :( What doesn't work?

> As I learn about other type of queries, some of them fail also.

again, what 'fail' means and which ruby commands fail.

> It would be really help ful if the IDE could run consoles as though they were terminal.
> So, I was reading that to run terminal inside the IDE might be possible also.  Is this correct?


> I was reading the docs and it's not clear to me, (not yet :)) if this is possible and how I would do that.


yes, it is possible (in theory).  But in this case you will not have code completion and other RM's "sugar" and you will not see prompts :(

Oleg.

0
Comment actions Permalink

Hi Oleg,

Thanks again for the quick reply :)


> It doesn't work if I put the whole set of commands on one line either.  Should it?

I'm not sure what do you mean here :( What doesn't work?

Well, this may not be allowed in Ruby, I suspect it is not at this point, but if I do the command like this:
     1.9.3p194 :003 > subjects.each do |subject|  puts subject.name  end

I get nothing but an empty prompt.  No error, just, an empty prompt



> As I learn about other type of queries, some of them fail also.

again, what 'fail' means and which ruby commands fail.

Well one behavior I was seeing was the return of only one "row" in a table where the query should have returned more than one or all of the rows.  I will have to try and recreate it of course.



> It would be really helpful if the IDE could run consoles as though they were terminal.
> So, I was reading that to run terminal inside the IDE might be possible also.  Is this correct?

When I say that, I mean consistant results as though I ran the query in terminal ;)

> I was reading the docs and it's not clear to me, (not yet :)) if this is possible and how I would do that.

yes,  it is possible (in theory).  But in this case you will not have code  completion and other RM's "sugar" and you will not see prompts :(

I appreciate the "sugar", really I do, but it becomes a bit "moot" if I can't know when the commands I am submitting to Rails is returning all of what I should see or not.  It's a bit les helpful if I have to double check in terminal. :p

Please know, I generally think that this IDE is very cool and is part of my motivtion to learn RoR B-)

Cheers,

-John

0
Comment actions Permalink

Hi John,

> Well, this may not be allowed in Ruby, I suspect it is not at this point, but if I do the command like this:
>     1.9.3p194 :003 > subjects.each do |subject|  puts subject.name  end
>
> I get nothing but an empty prompt.  No error, just, an empty prompt



the code is a correct ruby code.  I suspect the problem in something else.
E.g. you might run the consoles in different environment and thus use different databases.
I've just tried to reproduce the problem locally with RM 4.5.3 and everything works fine for me. (BTW what exect version do you use?)

Regards, Oleg.
0
Comment actions Permalink

Hi Oleg,

E.g. you might run the consoles in different environment and thus use different databases.

5.5.25a MySQL Community Server
  System Version:    Mac OS X 10.7.4 (11E2620)
  Kernel Version:    Darwin 11.4.2
ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-darwin11.4.2]
Rails 3.2.8

I've  just tried to reproduce the problem locally with RM 4.5.3 and  everything works fine for me. (BTW what exect version do you use?)

RM 4.5.3 Build 119.63

Thanks,

-John

0
Comment actions Permalink

> E.g. you might run the consoles in different environment and thus use different databases.

I meant rails environment. Rails have three environments - development/test/production, and for every
environment Rails use different database. RM asks which environment usewhen you run Rails console.

Oleg.

0

Please sign in to leave a comment.