Questions tagged [rails-console]

the interactive, command-line interface to the Ruby-based Rails framework. The Rails console allows developers to interact directly with their application without using a browser.

441 questions
115
votes
8 answers

Devise password reset from Rails console

While running an app how do you select a user by email address and then set the password manually within rails console for Devise? Also, where would I go to review documentation to cover more details in this regard to manipulation of accounts while…
ylluminate
  • 12,102
  • 17
  • 78
  • 152
101
votes
2 answers

Rails Console: reload! not reflecting changes in model files? What could be possible reason?

Earlier it was working fine. I have been playing little bit config. So may be i have changed some config unknowingly. here is config of environment/development.rb config.cache_classes = false # Log error messages when you accidentally call…
Maddy.Shik
  • 6,609
  • 18
  • 69
  • 98
74
votes
4 answers

Write to rails console

When I want to try or debug smthing I run rails console and do some stuff there. I can print some text or variables from code by raising exception with raise "blablabla". Question: How I can just write to rails console without exception raising (and…
71
votes
1 answer

Can I get the Ruby on Rails console to remember my command history, umm, better?

I'm using the console in Ruby on Rails 3.1.1, and I'm finding its command history (up arrow) to be really flaky. I've run the commands p = Product.by_name 'Acme' and p.add_search_term('Snipe') several times today, across several console sessions.…
jcollum
  • 43,623
  • 55
  • 191
  • 321
65
votes
7 answers

rails console doesn't start

I`m in root of my application, and when I type $ rails console It looks like something is loading, but nothing happens. And when I stop ^C I received this trace: ^C/home/jonatas/.rvm/gems/ruby-2.1.2/gems/spring-1.1.3/lib/spring/client/run.rb:54:in…
JonatasTeixeira
  • 1,474
  • 1
  • 18
  • 24
61
votes
12 answers

Truncate table(s) with rails console

I have this testingdatabase which, by now, is stuffed with junk. Now I've done a few Table.destroy_all commands in the rails console which deletes all records and dependencies which is awesome. However; I'd like to truncate everything so the ID's…
CaptainCarl
  • 3,411
  • 6
  • 38
  • 71
60
votes
6 answers

Rails Console find users by array of ids

So I have an array of user ids. Is there a way in rails console to query all of these user's with the array something like ids = [1, 2, 3, 4] users = User.find(ids) and have it return all 4 users?
Seth
  • 10,198
  • 10
  • 45
  • 68
59
votes
16 answers

Rails: NameError: uninitialized constant

I have a simple model called PhoneNumber: class PhoneNumber < ActiveRecord::Base validates :pnumber, presence: true, on: :create #=> { :message => " cannot be blank" } validates :pnumber, numericality: true, on: :create end I go to the root…
Nick
  • 2,924
  • 4
  • 36
  • 43
54
votes
5 answers

Equivalence of Rails console for Node.js

I am trying out Node.js Express framework, and looking for plugin that allows me to interact with my models via console, similar to Rails console. Is there such a thing in NodeJS world? If not, how can I interact with my Node.js models and data,…
AdamNYC
  • 19,887
  • 29
  • 98
  • 154
35
votes
5 answers

Rails Console - Find where created at = certain day

With Ruby on Rails console, is it possible to query the database for all records created on a certain day? something like date = "january 5 2013" users = User.find(:all, :conditions => {:created_at => date})
Seth
  • 10,198
  • 10
  • 45
  • 68
32
votes
1 answer

ActiveRecord appends 'AND (1=0)' to end of queries

I've been playing around in the rails console trying to get things to work, and I notice that one of my queries keeps returning nil when it shouldn't. Upon looking at the generated SQL query I notice that it has AND (1=0) appended to it each time. …
kingsfoil
  • 3,795
  • 7
  • 32
  • 56
30
votes
4 answers

Rails console: Unable to autoload constant

I have a Customer_ratings model that allows users to leave feedback on each other. The web app is working properly, and feedback is collected, stored and displayed. I wanted to go in and delete some feedback through the rails console, but when I…
dmt2989
  • 1,610
  • 3
  • 17
  • 30
29
votes
8 answers

'You do not have access to the app' when trying to access heroku console

I recently started collaborating in a project on Heroku using Ruby on Rails. I was added as a collaborator and added the remote to my environment. After some development, I pushed some changes and had no problems: $ git push staging Where staging…
25
votes
6 answers

Rails console not working on server

When I run bundle exec rails console production or rails console production via SSH on the server in the Current folder of the Capistrano deploy I get: Usage: rails new APP_PATH [options] Options: (...) with an explanation to start a new…
user2609980
  • 10,264
  • 15
  • 74
  • 143
24
votes
5 answers

Get rails associations from console

I have a model in my Rails application - User. I want all the associations to be listed in rails console, along with the type of association(1-1, 1-many).
shajin
  • 3,214
  • 5
  • 38
  • 53
1
2 3
29 30