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.
Questions tagged [rails-console]
441 questions
6
votes
2 answers
How to access class variable in Model class
I want to define the class variable test, threshold
so that I can use Order.test, Order.threshold in my Rails app
but I can not access the class variable when using the rails console
I must misunderstand something, where's the problem?…

newBike
- 14,385
- 29
- 109
- 192
6
votes
1 answer
Why does Rails console say "cannot load such file -- readline"?
I am new to Ruby on Rails, and am using RVM to manage Ruby versions.
My laptop has Ruby1.8.7 installed, but my project is using RVM, Ruby1.9.3 and Rails 3.2.11.
I can't run rails c or rails console without it giving me the following…

polarcare
- 575
- 1
- 6
- 24
6
votes
2 answers
clear all variables in rails console
can any body tell me what command is used to clear all variables in rails console?
e.g.
1.9.1 :001 > permissions = {:show => true}
=> {:show=>true}
1.9.1 :001 > foo = "bar"
=> "bar"
I need a command that can get all variables reset to nil…

Sarun Sermsuwan
- 3,608
- 5
- 34
- 46
5
votes
2 answers
Rails console shows value in scientific notation
I have model named Dish which has an attribute cost of float type. I've set precision to 15 and scale to 2. The problem is in rails console, the value for cost is displayed in scientific notation.
cost: 0.102e2
How to display in decimals?

Hariraj
- 65
- 8
5
votes
4 answers
accessing Rails Console after deploy to server
I´m having trouble to access the rails console in production.
I used Capistranoto deploy the app to a VPS
If I cd to deploy@myapp:~/myapp/current$and run bundle exec rails cthere I always get the option list for creating new rails project, like…

DaudiHell
- 808
- 10
- 32
5
votes
3 answers
Executing a command every time the rails console starts
I have a setup command that I want executed every time I start the rails console -
MyClass.some_method()
I get tired of retyping it each time I fire up rails c - is there a way to have it automatically get run every time a new console is…

user2490003
- 10,706
- 17
- 79
- 155
5
votes
4 answers
How to find and remove part of a string in Rails Console - ActiveRecord
I'm looking for a way in the rails console to find any values that finish with a particular string and remove that string from the value.
Something along the lines of:
Model.all.each{|x| x.duration.slice!(" weeks")}.where("duration IS NOT NULL")…

jake
- 91
- 2
- 6
5
votes
2 answers
rails console command not working
The rails console command is not working on digitalocean. I have also tried RAILS_ENV=staging bundle exec rails console.
Is this a known issue? Experts please help me.
It just shows rails command for creating new rails application.
I am using a…

Md Sirajus Salayhin
- 4,974
- 5
- 37
- 46
5
votes
2 answers
Ruby on Rails Seed Data
I am Ruby/Rails newbie. I am currently learning about the Rails console and databases using Rake and the seeds.rb file.
I am supposed to:
Add a post with a unique title and body to seeds.rb.
Before creating a unique post, verify it exists in the…

mp_jr
- 61
- 1
- 6
5
votes
1 answer
Rails 4.2 web-console issue
After upgrading to Rails 4.2, I was excited to try out the newly integrated web-console, but I'm having some issues.
In the release notes for Rails 4.2, it mentions: "New applications generated with Rails 4.2 now come with the Web Console gem by…

kevinweaver
- 523
- 1
- 4
- 14
5
votes
1 answer
How can I get a valid Authenticity Token with my Rails Console?
I am trying to use my rails console to call a public post method in my controller.
rails c
app.post '/servers/important_method'
This obviously gives me:
ActionController::InvalidAuthenticityToken (ActionController::InvalidAuthenticityToken):
Is…

Joe Eifert
- 1,306
- 14
- 29
5
votes
2 answers
Rails console error: Error loading ~/.pryrc: Command: `continue` not found
When I use the rails console on my current laptop (on any rails project), I get the following error when the console starts up.
Rails console error: Error loading ~/.pryrc: Command: `continue` not found
The console still loads and operates…

darkmoves
- 328
- 3
- 12
5
votes
3 answers
Ruby on Rails: Update Attribute
Google is seriously failing me right now. All I need to do is update one attribute, setting a user to admin, from the Heroku rails console.
I can't find a single simple answer. What I've been trying is:
Record.update_attribute(:roles_mask, "1")…

Ian Ellis
- 541
- 6
- 19
5
votes
2 answers
Rails - What happens when I convert an object into string?
I was playing with Rails Console. By chance, I accidentally convert an object into a string.
Below are my codes.
Rails Console
user = User.find(1)
user.to_s # returns
My question is, What is…

laman
- 552
- 6
- 18
5
votes
1 answer
Selecting second entry in rails console?
I need to select the second entry in the User model.
User.second does not work, nor does User.2 or User.two.
I'm trying to set u to the second User entry (u = User.2)

StackExchange User
- 1,222
- 14
- 35