Running in non-dev envs. with script/runner shebang setup


#1

All,

I have a script that runs script/runner via the shebang mechanism at the
top o the file, like so:

#!/usr/bin/env ./script/runner

This works fine in development, how would I get it to run in
non-development environments?

Thanks,
Wes


#2

$ script/runner -h

Usage: script/runner [options] (‘Some.ruby(code)’ or a filename)

 -e, --environment=name           Specifies the environment for

the runner to operate under (test/development/production).
Default: development

 -h, --help                       Show this help message.

[…]

The -e option is probably what you are looking for.


#3

That’s correct, but I can’t get it to work when the script/runner
command is in a file, like so:

import_physicians.rb:

#!/usr/bin/env ./script/runner -e production

If I run import_physicians.rb, this doesn’t work.

W


#4

Duh.

RAILS_ENV=production lib/import_physicians.rb

works fine.

W


#5

Im trying to see posts index page, In tat im showing category list,
im
using collect method it show error…

ActiveRecord::StatementInvalid in Posts#index
Showing app/views/posts/index.html.erb where line #19 raised:

Mysql::Error: Unknown column ‘categories_posts.category_id’ in ‘on
clause’: SELECT categories.* FROM categories INNER JOIN
categories_posts ON categories.id =
categories_posts.category_id WHERE ((categories_posts.post_id

1))

Extracted source (around line #19):

16:

<%= post.created_at.strftime(’%m/%d/%y %I:%m %p’) %>
17: <%= h(post.title) %>
18: <%= h(post.author.display_name) if post.author %>
19: <%= post.categories.collect {|cat| [cat.name] }.join(",")
%>
20: <%= h(post.status) %>
21: <%= post.comments_count %>

pls help me, im new to RoR…??