How to run commands like "rails generate controller"

In my rails 3.1 project i want to generate controller from command line:

rails generate controller some_controller new

but in Rails console I've got:NameError: undefined local variable or method `new'

So I dont quite understand where should I pass the rails standard commands in RubyMine.

5 comments
Comment actions Permalink

Hi Alex,

On the Tools menu there is an option for 'Run Rails Generator...' (on Windows and Linux the shortcut is Ctrl-Alt-G) which will allow you to just type in 'controller.....' and then it'll do the rest for you.

Is that any use?

Geoff

0
Comment actions Permalink

Well what i ment: is it possible to run custom console command (for example rake or some custom generator added by gems) from RubyMine?

0
Comment actions Permalink

Ah, I'm with you: I've only just started using RubyMine myself so I thought it seemed a rather obvious answer... but I know that sometimes it's the obvious staring me in the face that I miss!

As for adding new rake tasks and such, isn't there a rescan rake tasks option - I'm not on my machine with RubyMine at the moment so I cannot check, but I'm pretty sure I recall some such item. I wouldn't be at all surprised if one of the background inspector tasks didn't keep scanning for new tasks anyway.

If you haven't found the answer and no-one else has answered by the time I get home I'll have a hunt to find it. :)

Later:

Menu 'Tools | Rake Tasks | Reload Rake Tasks' - I just tried adding a custom rake task and then ran this, it picked up my rake task with no problem.

Geoff

0
Comment actions Permalink

Do you mean command "Reload rake task"? Well I dont know what does it do. Do it scans gems for adding new comands? I'm not sure

and how to add new generators in "Run Rails Generator" tool? If for example after I install nifty_generators gem?

I just thought maybe threre is a buildin console for rails (rake) commands.

0
Comment actions Permalink

Yes, that's precisely what it seems to do: add a generator gem then reload rake tasks and it scans the gems finding the new rake tasks.

If you open the little popup with 'run rails generator', start typing the name of the generator and you'll get a picklist of available matches.

Actually, after playing further - I don't think you need to do the reload rake tasks to get the generators listed, it looks likes it picks them up automagically... really must search for a manual for this instead of guessing all the time.   I'm enjoying it too much though! :D

There's a regular rails console available off the Tools menu - pick which environment you want to use - for testing with. Rake tasks all kick off from the rake option on the same menu.  I'm not sure what action it is you're trying to get at that isn't covered by those two or the 'run rails generator' (again on the tools menu)?

0

Please sign in to leave a comment.