rake

rails can't find rake gem

只愿长相守 提交于 2019-12-09 08:30:16
问题 I have a basic Rails app running in docker. I can start it up just fine and serve responses. I can run rake -T just fine. But I cannot run a Rails generate command. It fails telling me Could not find rake-12.3.1 in any of the sources $ docker-compose run main bundle exec rails generate controller Welcome index Starting cognitopoc_db_1 ... done Could not find rake-12.3.1 in any of the sources Run `bundle install` to install missing gems. Here is my bundle env: $ docker-compose run main bundle

NoMethodError: undefined method `on' for main:Object

元气小坏坏 提交于 2019-12-09 08:11:14
问题 when I try to bundle exec cap production deploy --trace I get an error message: deploy@h2540559:/www/apps/foodsoft$ bundle exec cap production deploy --trace ** Invoke production (first_time) ** Execute production ** Invoke load:defaults (first_time) ** Execute load:defaults ** Invoke rvm:hook (first_time) ** Execute rvm:hook cap aborted! NoMethodError: undefined method `on' for main:Object /usr/local/rvm/gems/ruby-2.0.0-p643/gems/capistrano-rvm-0.1.2/lib/capistrano/tasks/rvm.rake:17:in

How can I pass named arguments to a Rake task?

寵の児 提交于 2019-12-09 07:41:12
问题 Is there a way to pass named arguments to a Rake task without using environment variables? I am aware that Rake tasks can accept arguments in two formats: Environment Variables $ rake my_task foo=bar This creates an environment variable with the name foo and the value bar that can be accessed in the Rake task my_task by ENV['foo'] . Rake Task Arguments $ rake my_task['foo','bar'] This passes the values foo and bar to the first two task arguments (if they are defined). If my_task were defined

How do you declare a Rake task that depends on a parameterized task?

落花浮王杯 提交于 2019-12-09 07:36:13
问题 I have seen examples where a task has parameters and a dependency task like: task :name, [:first_name, :last_name] => [:pre_name] do |t, args| args.with_defaults(:first_name => "John", :last_name => "Dough") puts "First name is #{args.first_name}" puts "Last name is #{args.last_name}" end How would you pass parameters to the name task if it was a task dependency like: task :sendLetter => :name #do something end 回答1: Args are passed down through the call stack. You just need to make sure your

how to do “press enter to exit” in batch

二次信任 提交于 2019-12-09 07:23:34
问题 I am using rake to build my project and I have a build.bat file similar to this: @echo off cls rake When I double click on build.bat the dos window pops up and shows all the progress but closes itself when the task is finished. Is there way to do a Console.ReadLine so that user can get a chance to see the log? Thanks. Updated: I've tried below but didn't work. not sure why. @echo off cls rake pause 回答1: Default interpreters from Microsoft are done in a way, that causes them exit when they

rake db:migrate error (Function 'inotify_init' not found)

♀尐吖头ヾ 提交于 2019-12-09 07:13:24
问题 I just got done setting up my rails environment on my old mac book and ran into this error. I've installed FFI and rb-inotify. I've also ran bundle install again. I've looked at https://github.com/ffi/ffi/issues/66 and https://groups.google.com/forum/?fromgroups=#!topic/ruby-ffi/gj3_k34o80k which both indicate that this is a linux specific API. There is a suggestion on the second of those links that says I should just remove that gem and things that depend on it, but I am hesitant to remove

How does rake db::migrate actually work

喜夏-厌秋 提交于 2019-12-09 05:47:16
问题 I've just really started with Ruby and Rails, and one of the things that I find myself really enjoying is the conventions it makes you use. I want to mimic that behavior in my own non-Ruby projects. My question is how does it actually work? I know I can look through the Rails code, but I'm not that far enough in my understanding to know what's going on in it. I know that it takes a baseline script and then runs update schema changes against it. But how does it know what version it's on? How

render_to_string from a rake task

妖精的绣舞 提交于 2019-12-09 04:44:27
问题 I want to use a Rake task to cache my sitemap so that requests for sitemap.xml won't take forever. Here's what I have so far: @posts = Post.all sitemap = render_to_string :template => 'sitemap/sitemap', :locals => {:posts => @posts}, :layout => false Rails.cache.write('sitemap', sitemap) But when I try to run this, I get an error: undefined local variable or method `headers' for #<Object:0x100177298> How can I render a template to a string from within Rake? 回答1: Here's how I did it: av =

Rails: Help with rake aborted error!

人走茶凉 提交于 2019-12-09 02:27:31
I have been trying to run the rake db:migrate command but it ain't working. I uninstalled and installed the gem but no luck. I read somewhere the o.9 wasn't stable and that 0.8.7 was ok. I tried it but I got an error also.. For now the error is Fayimora-Femi-Baloguns-MacBook-Pro:sample_app fayimora$ bundle exec rake db:migrate /Library/Ruby/Gems/1.8/gems/bundler-1.0.15/lib/bundler/runtime.rb:136: warning: Insecure world writable dir /usr/local in PATH, mode 040777 /Library/Ruby/Gems/1.8/gems/bundler-1.0.15/lib/bundler/runtime.rb:136: warning: Insecure world writable dir /usr/local in PATH,

Error creating Rails DB using rake db:create

江枫思渺然 提交于 2019-12-09 00:59:50
问题 I'm attempting to get my first "hello world" rails example going using the rails' getting started guide on my OSX 10.6.3 box. When I go to execute the first rake db:create command (I'm using mysql) I get: simon@/Users/simon/source/rails/blog/config: rake db:create (in /Users/simon/source/rails/blog) Couldn't create database for {"reconnect"=>false, "encoding"=>"utf8", "username"=>"root", "adapter"=>"mysql", "database"=>"blog_development", "pool"=>5, "password"=>nil, "socket"=>"/opt/local/var