3

I need to wirte a bash script to run commands in my rails console, the commands are : Station.create(......)

 #!/bin/bash
 rails console

After this line i have no ideas. i tried echo "Station.create(...), but it doesn't help

asked Feb 11, 2016 at 19:54

1 Answer 1

7

You want runner.

#/bin/bash
# Maybe need to prefix with `bundle exec`
rails runner 'Station.create(...)'
answered Feb 11, 2016 at 21:23
Sign up to request clarification or add additional context in comments.

2 Comments

when i try to create a new station in rails console it does not create a new record. #!/bin/bash rails runner 'Station.create(cd:"BK",station: "bla", icao: "BKBK", iata:"BKK", synop:"77777", lat:"55.55", lon:"555.55", elev: "5", mflag: "K", nexrad:"K", country_code:"BK", plotting:"5")' exit 0
That I can't help with other than to try it in the console and look for errors.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.