FAQ Database Discussion Community


Rails Console not starting up

ruby-on-rails,ruby,rails-console
I am trying to run rails console rails c in ConEmu and Cmder but get the following error.... C:/Ruby21-x64/lib/ruby/2.1.0/open-uri.rb:30:in `initialize': No such file or directory @ rb_sysopen - C:/Users/user.name/Documents/parentDir/app_dir/log/app_dev.log (Errno::ENOENT) from C:/Ruby21-x64/lib/ruby/2.1.0/open-uri.rb:30:in `open' from C:/Ruby21-x64/lib/ruby/2.1.0/open-uri.rb:30:in `open' from C:/Ruby21-x64/lib/ruby/2.1.0/open-uri.rb:30:in `open' from C:/Ruby21-x64/lib/ruby/2.1.0/logger.rb:600:in `create_l ogfile' from...

Rails Hirb in console for outputting long data breaks console

ruby-on-rails,rails-console,hirb
I'm using Rails 4.2 with Hirb in console. and when I try to output long/big data in console. the console breaks. it shows (END) and I can't type or run other commands anymore, and what I must do in order to fix is to close the console. Is there any...

In the rails 4 console, how do I log all sql activity to file BUT not to the console output?

ruby-on-rails-4,activerecord,logging,rails-console
Lots of similar questions ask how to hide sql logs in the console window, and the answers suggest changing the log level of Active Record or turning off AR logging altogether. However I still want AR to log everything, I just wanted to log it to file only, and not...

Rails console setting limit to one on queries

ruby-on-rails,rails-activerecord,rails-console,ruby-on-rails-4.2
When I run ActiveRecord queries, the Rails Console seems to be appending LIMIT 1 to my queries. So I have a sheet which has_many slots. When I query Slot.find_by(sheet_id: 96), I get: Slot Load (2.3ms) SELECT "slots".* FROM "slots" WHERE "slots"."sheet_id" = ? LIMIT 1 [["sheet_id", 96]] => #<Slot id:...

Neo4j - Query results random order

ruby-on-rails,neo4j,rails-console,neo4j.rb
I'm not exactly sure what's gone on inside my app but my queries don't seem to give me my results in order of creation. It recently rearranged itself without me changing the code related to the query. However, I've obviously done SOMETHING. At one point I was trying to get...

Cant make my rails console work

ruby,rbenv,rails-console
[email protected]:~/Appp$ rbenv local rbenv: no local version configured for this directory [email protected]:~/Appp$ rbenv global 2.2.1 [email protected]:~/Appp$ rbenv versions * 2.2.1 (set by /home/eze/.rbenv/version) I recently uninstalled and reinstalled ruby with rbenv, but when I installed again I realized that everything worked except from the rails console, this is the output...

Rails - searching in the console

ruby-on-rails,rails-console
I am trying to make an app with Rails 4 and Simple Form. I have three models, being: Project, Scope and Background. Project has one scope. Scope has one background. Scope belongs to project. Background belongs to scope. Project accepts nested attributes for Scope. Scope accepts nested attributes for background....

Admin set to true not working on Rails after forgetting to register first the admin email in app

ruby-on-rails,devise,user,admin,rails-console
I have created a users' registration/signedup through Devise gem. To give a user an admin role I've added a new column in users table (giving the command in the terminal followed by rake db:migrate) named "admin" and set all to "false" by default: class AddAdminToUsers < ActiveRecord::Migration def change add_column...

Creating new post via Rails Console and passing validation

ruby-on-rails,ruby,validation,rails-console,pry
Ruby newbie here. I'm currently working on an assignment that has me validate posts. This is what my post.rb looks like: class Post < ActiveRecord::Base has_many :comments belongs_to :user belongs_to :topic default_scope { order('created_at DESC') } validates :title, length: { minimum: 5 }, presence: true validates :body, length: { minimum:...

Can't generate migration in rails console

ruby-on-rails,rails-console
For some reason I am suddenly unable to generate a migration from my rails console and am unsure how to interpret the error. I believe it has to do with a problem from when I tried to remove refinery cms early on. Here is an example of the error: 2.1.3...

Why is reject not working on my Hash even though the condition is true?

ruby-on-rails,arrays,ruby,hash,rails-console
I have the following hash {"goes_by"=>[nil, ""], "middle_name"=>[nil, ""], "suffix"=>[nil, ""], "jersey"=>["8", "8A"]} I'm trying to write a statement to reject any elements that have a nested array with nil & "". So I wrote the following command to try and perform this but it returns nil as if there...