Forum: Ruby on Rails Running in non-dev envs. with script/runner shebang setup

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Wes G. (Guest)
on 2009-04-24 12:39
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
Johannes Huning (Guest)
on 2009-04-24 13:12
(Received via mailing list)
Attachment: PGP.sig (0 Bytes)
$ 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.
Wes G. (Guest)
on 2009-04-24 18:59
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
Wes G. (Guest)
on 2009-04-24 19:10
Duh.

RAILS_ENV=production lib/import_physicians.rb

works fine.

W
haneef5k (Guest)
on 2009-04-24 19:21
(Received via mailing list)
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:     <td><%= post.created_at.strftime('%m/%d/%y %I:%m %p') %></td>
17:     <td><%= h(post.title) %></td>
18:     <td><%= h(post.author.display_name) if post.author %></td>
19:     <td><%= post.categories.collect {|cat| [cat.name] }.join(",")
%>
20:     <td><%= h(post.status) %></td>
21:     <td><%= post.comments_count %>


pls help me,, im new to RoR..??
This topic is locked and can not be replied to.