Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Run ruby file in rails console

I've created a file ebm.rb script to add new entries to a database in rails.

The file is very long, and uses some rails models.

Can I easily execute ebm.rb in the rails console?

I tried something with load and require, but that didn't work. My ebm.rb file is located in C:\Sites\ebm and my rails project in C:\Sites\rublesql.

like image 570
Em Sta Avatar asked Aug 13 '26 07:08

Em Sta


1 Answers

You can run the code in the file in the context of your rails app with

rails runner

http://guides.rubyonrails.org/command_line.html#rails-runner

like image 194
DanSingerman Avatar answered Aug 15 '26 04:08

DanSingerman



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!