Reputation: 3264
When I type large ActiveRecord queries,Before finishing the query, the line is breaking and I can't even reading or typing the command properly.I am using ubuntu.Any solution?
Upvotes: 6
Views: 3147
Reputation: 3264
Finally narrowed the issue to be with resizing the terminal.Usually I maximize the terminal for typing large commands , hence the problem. Found out that this can be solved by handling the SIGWINCH signal to resize IRB.In the solution below i am also resizing Hirb.
Add the following lines to ~/.irbrc (create one if it doesn't exist) :
Signal.trap('SIGWINCH', proc { y, x = `stty size`.split.map(&:to_i); Hirb::View.resize(x, y) if defined? Hirb } )
Upvotes: 8
Reputation: 21791
I've noticed the same bug with irb, rails console uses irb by default. That's why I'm using pry, look here how to setup pry with rails.
Upvotes: 1
Reputation: 5317
A more generic way is using a \
at the end of your line.
Using the same example of "Kenny Grant"
ruby> User.very.long.chain.of.arel.commands. \
where('thing = ?', 4).very.long.chain.of.arel.commands
the last line should not have any ending \
and then the whole command will be executed.
Upvotes: 3
Reputation: 9623
If your query is like this:
rails c
ruby> User.very.long.chain.of.arel.commands.where('thing = ?',4).very.long.chain.of.arel.commands
You should be able to do this:
ruby> User.very.long.chain.of.arel.commands.where('thing = ?',
4).very.long.chain.of.arel.commands
and split it on any commas within the conditions, then when you press return at the end it will execute.
Upvotes: 0