rails-console

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

风格不统一 提交于 2019-12-17 07:15:53
问题 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 methods on nil. config.whiny_nils = true # Show full error reports and disable caching config.consider_all_requests_local = true config.action_view.debug_rjs = true config.action_controller.perform_caching = false # Don't care if the mailer can't send

Init some variables when opening rails console

筅森魡賤 提交于 2019-12-11 14:48:47
问题 Here's the thing. I use quite a lot the console to test my methods before plugging them in my app (nothing new here I guess). What I'd find convenient, would be to have like a console_seed.rb file that I would load and then all my variables are ready for use. Ex: console_seed.rb me = User.find(77) other_person = User.find(89) So I can immediately test: me.add_friend(other_person) when opening the console, without having to write the .find() lines again and again. I found this post : how can I

Heroku pipeline. Run commands on production app (not staging)

房东的猫 提交于 2019-12-11 07:30:22
问题 I am using the heroku pipeline. I set up my two apps. One for staging, one for production. Both use "production" as the environment variable. If I run heroku run rails c I can access the console on my staging app. The heroku website, allows to run a console in the production app as well, but only with the predifined heroku run part. Which means if for whatever reason I need to run a more fundamental command (for example heroku pg:reset ; I know I know), I can't. So is there a way to specify

How to run code automatically when launching a Rails console?

偶尔善良 提交于 2019-12-11 03:52:35
问题 Let's say I wanted a greeting every time the Rails console comes up: Scotts-MBP-4:ucode scott$ rails c Loading development environment (Rails 4.2.1) Hello there! I'm a custom greeting 2.1.5 :001 > Where would I put the puts 'Hello there! I\'m a custom greeting' statement? Another Stackoverflow answer suggested, and I've read this elsewhere too, that I can put that in an initializer like this: # config/initializers/console_greeting.rb if defined?(Rails::Console) puts 'Hello there! I\'m a

Ruby on Rails: Data not saving ActiveRecord

99封情书 提交于 2019-12-10 12:09:58
问题 I'm pretty new to Ruby on Rails and I've been trying to develop a simple blog. However when I try to save the new Post, the page reloads a new page and no data is saved. The data however is present in the URI. Here's my controller: class PostsController < ApplicationController before_action :set_post, only: [:show, :edit, :update, :destroy] # GET /posts # GET /posts.json def index @posts = Post.all end # GET /posts/1 # GET /posts/1.json def show end # GET /posts/new def new @post = Post.new

Rails console (END) how to get past it?

随声附和 提交于 2019-12-07 01:37:12
问题 working in the Rails console, I pasted a very long hash into the console and when I scrolled ot the bottom of it it has the token (END) but the only way I've found to get past it is to exit the console with CTRL+Z. This defeats my purpose in using the console for testing some code out. Is there any other way to get past that (END) token? 回答1: stumbled over this problem, after some tries I found the solution :) ⇧ shift + Q Edit: as mentioned by @Paul, only Q will suffice. 回答2: What about Ctrl

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

こ雲淡風輕ζ 提交于 2019-12-06 17:30:39
问题 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 is the name of my remote. Later, when trying to run "rake test" on Heroku, I recieved an error: $heroku run rake test --app staging Running `rake test` attached to terminal... failed ! You do not have access to the app staging. Which is odd, as I was

Rails console issues using JRuby: no prompt character, no tab completion, broken arrow keys, etc

帅比萌擦擦* 提交于 2019-12-05 17:01:06
问题 I'm having various issues with my Rails console under JRuby, including No prompt character Tab completion not working (literal tab gets inserted) Up/down arrows not browsing history ( ^[[A or ^[[B gets inserted, respectively) Left/right arrows not moving cursor ( ^[[D or ^[[C gets inserted, respectively) Home / End keys not moving cursor to beginning/end of line (instead 1~ or 4~ inserted, respectively); Ctrl + a / Ctrl + e work though Ctrl + c killing console instead of killing the line I'm

Rails 3 Sandbox Console

好久不见. 提交于 2019-12-05 12:52:35
问题 In Rails 2 you're able to run script/console --sandbox so you can play with production data and not accidentally break anything. I can't seem to find the equivalent command for Rails 3. Does anyone know what it is? 回答1: Easy, type in: bundle exec rails c -s and that is it. $ bundle exec rails c --help Usage: console [environment] [options] -s, --sandbox Rollback database modifications on exit. --debugger Enable ruby-debugging for the console. --irb DEPRECATED: Invoke `/your/choice/of/ruby

Rails console (END) how to get past it?

浪尽此生 提交于 2019-12-05 05:38:26
working in the Rails console, I pasted a very long hash into the console and when I scrolled ot the bottom of it it has the token (END) but the only way I've found to get past it is to exit the console with CTRL+Z. This defeats my purpose in using the console for testing some code out. Is there any other way to get past that (END) token? stumbled over this problem, after some tries I found the solution :) ⇧ shift + Q Edit: as mentioned by @Paul, only Q will suffice. What about Ctrl+C? It should continue without exiting the console. 来源: https://stackoverflow.com/questions/15958146/rails-console