Heroku and Substruct - lets collaboratively write a guide

瀏覽次數:12 次
跳到第一則未讀訊息

brightbyte8

未讀,
2010年3月18日 上午9:51:502010/3/18
收件者:substruct
Hi guys,

I love the substruct project - I looked at Spree and it was far too
complicated for my needs. Substruct is perfect for uses such as
digital downnloads and doesn't get enough press at all.

Today I've been modding my substruct install to work with Heroku. Here
are all the tips so far - I'm not completely there yet but it's well
on it's way. Any extra help is appreciated (you can see the bit I am
stuck with at the bottom of the page).

#S3 storage for photos and downloads
1. The Asset, Image and Download models you must change the
has_attachment bit to include
:storage => :s3
2. Add a amazon_s3.yml file in the config dir

#Stop JS caching from giving you read only errors on Heroku
3. In the production initializer set
config.action_controller.perform_caching = false

# Stop SSL error
4. In Heroku use the SSL piggyback addon (free)

At the app will work on Heroku - at least some pages. However on the
products page I get this error:

NameError (uninitialized constant StoreController::ActiveMerchant):
/vendor/rails/activesupport/lib/active_support/dependencies.rb:493:in
`const_missing'
/vendor/plugins/substruct/app/controllers/store_controller.rb:5
/usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in
`gem_original_require'
/usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in
`require'
/vendor/rails/activesupport/lib/active_support/dependencies.rb:510:in
`require'
/vendor/rails/activesupport/lib/active_support/dependencies.rb:355:in
`new_constants_in'
/vendor/rails/activesupport/lib/active_support/dependencies.rb:510:in
`require'
/vendor/rails/activesupport/lib/active_support/dependencies.rb:102:in
`require_or_load_without_engine_additions'
/vendor/plugins/engines/lib/engines/rails_extensions/dependencies.rb:
115:in `require_or_load'
/vendor/plugins/engines/lib/engines/rails_extensions/dependencies.rb:
110:in `each'
/vendor/plugins/engines/lib/engines/rails_extensions/dependencies.rb:
110:in `require_or_load'
/vendor/plugins/engines/lib/engines/rails_extensions/dependencies.rb:
101:in `each'
/vendor/plugins/engines/lib/engines/rails_extensions/dependencies.rb:
101:in `require_or_load'
/vendor/rails/activesupport/lib/active_support/dependencies.rb:261:in
`load_missing_constant'
/vendor/rails/activesupport/lib/active_support/dependencies.rb:468:in
`const_missing'
/vendor/rails/activesupport/lib/active_support/dependencies.rb:480:in
`const_missing'
/vendor/rails/activesupport/lib/active_support/inflector.rb:285:in
`constantize'
/vendor/rails/activesupport/lib/active_support/inflector.rb:284:in
`each'
/vendor/rails/activesupport/lib/active_support/inflector.rb:284:in
`constantize'
/vendor/rails/activesupport/lib/active_support/core_ext/string/
inflections.rb:143:in `constantize'
/vendor/rails/actionpack/lib/action_controller/routing/route_set.rb:
387:in `recognize'
/vendor/rails/actionpack/lib/action_controller/dispatcher.rb:148:in
`handle_request'
/vendor/rails/actionpack/lib/action_controller/dispatcher.rb:107:in
`dispatch'
/vendor/rails/actionpack/lib/action_controller/dispatcher.rb:104:in
`synchronize'
/vendor/rails/actionpack/lib/action_controller/dispatcher.rb:104:in
`dispatch'
/vendor/rails/actionpack/lib/action_controller/dispatcher.rb:120:in
`dispatch_cgi'
/vendor/rails/actionpack/lib/action_controller/dispatcher.rb:35:in
`dispatch'
/usr/local/lib/ruby/gems/1.8/gems/thin-1.0.1/lib/rack/adapter/rails.rb:
60:in `serve_rails'
/usr/local/lib/ruby/gems/1.8/gems/thin-1.0.1/lib/rack/adapter/rails.rb:
80:in `call'
/home/heroku_rack/lib/static_assets.rb:9:in `call'
/home/heroku_rack/lib/last_access.rb:25:in `call'
/usr/local/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/urlmap.rb:46:in
`call'
/usr/local/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/urlmap.rb:40:in
`each'
/usr/local/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/urlmap.rb:40:in
`call'
/home/heroku_rack/lib/date_header.rb:14:in `call'
/usr/local/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/builder.rb:60:in
`call'
/usr/local/lib/ruby/gems/1.8/gems/thin-1.0.1/lib/thin/connection.rb:
80:in `pre_process'
/usr/local/lib/ruby/gems/1.8/gems/thin-1.0.1/lib/thin/connection.rb:
78:in `catch'
/usr/local/lib/ruby/gems/1.8/gems/thin-1.0.1/lib/thin/connection.rb:
78:in `pre_process'
/usr/local/lib/ruby/gems/1.8/gems/thin-1.0.1/lib/thin/connection.rb:
57:in `process'
/usr/local/lib/ruby/gems/1.8/gems/thin-1.0.1/lib/thin/connection.rb:
42:in `receive_data'
/usr/local/lib/ruby/gems/1.8/gems/eventmachine-0.12.6/lib/
eventmachine.rb:240:in `run_machine'
/usr/local/lib/ruby/gems/1.8/gems/eventmachine-0.12.6/lib/
eventmachine.rb:240:in `run'
/usr/local/lib/ruby/gems/1.8/gems/thin-1.0.1/lib/thin/backends/base.rb:
57:in `start'
/usr/local/lib/ruby/gems/1.8/gems/thin-1.0.1/lib/thin/server.rb:150:in
`start'
/usr/local/lib/ruby/gems/1.8/gems/thin-1.0.1/lib/thin/controllers/
controller.rb:80:in `start'
/usr/local/lib/ruby/gems/1.8/gems/thin-1.0.1/lib/thin/runner.rb:173:in
`send'
/usr/local/lib/ruby/gems/1.8/gems/thin-1.0.1/lib/thin/runner.rb:173:in
`run_command'
/usr/local/lib/ruby/gems/1.8/gems/thin-1.0.1/lib/thin/runner.rb:139:in
`run!'
/usr/local/lib/ruby/gems/1.8/gems/thin-1.0.1/bin/thin:6
/usr/local/bin/thin:20:in `load'
/usr/local/bin/thin:20


Here it looks like store_controller.rb 5 is the offender. It reads:

include ActiveMerchant::Billing::Integrations

Anyone got any ideas on how to get past this (I've been trying for 3
hours with no luck)?

Cheers,

Jack Kinsella


Roger Pack

未讀,
2010年3月18日 下午3:22:422010/3/18
收件者:subs...@googlegroups.com
> At the app will work on Heroku - at least some pages. However on the
> products page I get this error:
>
> NameError (uninitialized constant StoreController::ActiveMerchant):
> /vendor/rails/activesupport/lib/active_support/dependencies.rb:493:in
> `const_missing'

I assume you have active merchant in your plugins directory?

brightbyte8

未讀,
2010年3月18日 晚上8:17:392010/3/18
收件者:substruct
I did on my machine - but it was installed as a git submodule meaning
that it wasn't committed to heroku. Solved with:
git rm --cached vendor/plugins/active_merchant
then adding and recommitting

brightbyte8

未讀,
2010年3月18日 晚上8:18:492010/3/18
收件者:substruct
Next issue is one with postgres and null values:

Processing StoreController#index (for 86.43.169.16 at 2010-03-18
11:14:31) [GET]
Session ID: a53ec50760a8996fbb602efb024ded7c
Parameters: {"action"=>"index", "controller"=>"store"}


ActiveRecord::StatementInvalid (PGError: ERROR: null value in column
"order_status_code_id" violates not-null constraint
: INSERT INTO "orders" ("created_on", "product_cost", "tax",
"order_user_id", "shipping_address_id", "affiliate_id",
"billing_address_id", "shipped_on", "order_shipping_type_id", "notes",
"promotion_id", "referer", "order_number", "shipping_cost",
"auth_transaction_id", "order_account_id", "order_status_code_id",
"affiliate_payment_id") VALUES('2010-03-18 11:14:31.642698', 0.0, 0.0,
NULL, 0, 0, 0, NULL, 1, NULL, 0, NULL, 465505228, 0.0, NULL, 0, NULL,
0) RETURNING "id"):
/vendor/rails/activerecord/lib/active_record/connection_adapters/
abstract_adapter.rb:147:in `log'
/vendor/rails/activerecord/lib/active_record/connection_adapters/
postgresql_adapter.rb:484:in `execute'
/vendor/rails/activerecord/lib/active_record/connection_adapters/
postgresql_adapter.rb:929:in `select_raw'
/vendor/rails/activerecord/lib/active_record/connection_adapters/
postgresql_adapter.rb:916:in `select'
/vendor/rails/activerecord/lib/active_record/connection_adapters/
abstract/database_statements.rb:7:in `select_all_without_query_cache'
/vendor/rails/activerecord/lib/active_record/connection_adapters/
abstract/query_cache.rb:59:in `select_all'
/vendor/rails/activerecord/lib/active_record/connection_adapters/
abstract/query_cache.rb:80:in `cache_sql'
/vendor/rails/activerecord/lib/active_record/connection_adapters/
abstract/query_cache.rb:59:in `select_all'
/vendor/rails/activerecord/lib/active_record/connection_adapters/
abstract/database_statements.rb:13:in `select_one'
/vendor/rails/activerecord/lib/active_record/connection_adapters/
abstract/database_statements.rb:19:in `select_value'
/vendor/rails/activerecord/lib/active_record/connection_adapters/
postgresql_adapter.rb:433:in `insert'
/vendor/rails/activerecord/lib/active_record/base.rb:2517:in
`create_without_callbacks'
/vendor/rails/activerecord/lib/active_record/callbacks.rb:220:in
`create_without_timestamps'
/vendor/rails/activerecord/lib/active_record/timestamp.rb:29:in
`create'
/vendor/rails/activerecord/lib/active_record/base.rb:2483:in
`create_or_update_without_callbacks'
/vendor/rails/activerecord/lib/active_record/callbacks.rb:207:in
`create_or_update'
/vendor/rails/activerecord/lib/active_record/base.rb:2217:in
`save_without_validation!'
/vendor/rails/activerecord/lib/active_record/validations.rb:921:in
`save_without_dirty!'
/vendor/rails/activerecord/lib/active_record/dirty.rb:83:in
`save_without_transactions!'
/vendor/rails/activerecord/lib/active_record/transactions.rb:
110:in `save!'
/vendor/rails/activerecord/lib/active_record/connection_adapters/
abstract/database_statements.rb:66:in `transaction'
/vendor/rails/activerecord/lib/active_record/transactions.rb:79:in
`transaction'
/vendor/rails/activerecord/lib/active_record/transactions.rb:98:in
`transaction'
/vendor/rails/activerecord/lib/active_record/transactions.rb:
110:in `save!'
/vendor/rails/activerecord/lib/active_record/transactions.rb:
118:in `rollback_active_record_state!'
/vendor/rails/activerecord/lib/active_record/transactions.rb:
110:in `save!'
/vendor/rails/activerecord/lib/active_record/validations.rb:892:in
`create!'
/vendor/plugins/substruct/app/controllers/store_controller.rb:
375:in `prep_store_vars'
/vendor/rails/activesupport/lib/active_support/callbacks.rb:173:in
`send'
/vendor/rails/activesupport/lib/active_support/callbacks.rb:173:in
`evaluate_method'
/vendor/rails/activesupport/lib/active_support/callbacks.rb:161:in
`call'
/vendor/rails/actionpack/lib/action_controller/filters.rb:191:in
`call'
/vendor/rails/actionpack/lib/action_controller/filters.rb:591:in
`run_before_filters'
/vendor/rails/actionpack/lib/action_controller/filters.rb:577:in
`call_filters'
/vendor/rails/actionpack/lib/action_controller/filters.rb:572:in
`perform_action_without_benchmark'
/vendor/rails/actionpack/lib/action_controller/benchmarking.rb:
68:in `perform_action_without_rescue'

Anyone any idea?

On Mar 18, 7:22 pm, Roger Pack <rogerdp...@gmail.com> wrote:

brightbyte8

未讀,
2010年3月18日 晚上8:20:472010/3/18
收件者:substruct
To add to guide:

Line 12 of questions controller caused an error due to how the find
condition was phrased

changed from:

@questions = Question.find(
:all,
:conditions => "featured = 1 ",
:order => "-rank DESC, times_viewed DESC"
)

to:

@questions = Question.find(
:all,
:conditions => [ "featured = ?", true],
:order => "-rank DESC, times_viewed DESC"
)

solving a postgre error

Roger Pack

未讀,
2010年3月19日 上午10:54:592010/3/19
收件者:subs...@googlegroups.com
>  @questions = Question.find(
>      :all,
>      :conditions => [ "featured = ?", true],
>      :order => "-rank DESC, times_viewed DESC"
>    )
>
> solving a postgre error

submit a patch :)
-r

回覆所有人
回覆作者
轉寄
0 則新訊息