RefineryCMS integration with existing Rails 3.1+ app - ruby-on-rails

I am following the guide at RefineryCMS site and when I try to rails generate refinery:cms I keep getting this error:
`require': cannot load such file -- refinerycms-base (LoadError)
The Gemfile looks as follows:
source 'https://rubygems.org'
gem 'rails', '3.2.2'
gem 'devise' #,'~> 1.4.0'
# Bundle edge Rails instead:
# gem 'rails'#, :git => 'git://github.com/rails/rails.git'
gem 'sqlite3'
#gem 'refinerycms'#, :git => 'git://github.com/resolve/refinerycms.git'
gem 'refinerycms-core'#, :git => 'git://github.com/resolve/refinerycms.git'
gem 'refinerycms-dashboard'#, :git => 'git://github.com/resolve/refinerycms.git'
gem 'refinerycms-images'#, :git => 'git://github.com/resolve/refinerycms.git'
gem 'refinerycms-pages'#, :git => 'git://github.com/resolve/refinerycms.git'
gem 'refinerycms-resources'#, :git => 'git://github.com/resolve/refinerycms.git'
gem 'refinerycms-settings'#, :git => 'git://github.com/parndt/refinerycms-settings.git'
gem 'refinerycms-generators'#, :git => 'git://github.com/resolve/refinerycms-generators.git'
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails', '~> 3.2.3'
gem 'coffee-rails', '~> 3.2.1'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer'
gem 'uglifier', '>= 1.0.3'
end
gem 'jquery-rails'
# To use ActiveModel has_secure_password
# gem 'bcrypt-ruby'#, '~> 3.0.0'
# To use Jbuilder templates for JSON
# gem 'jbuilder'
# Use unicorn as the app server
# gem 'unicorn'
# Deploy with Capistrano
# gem 'capistrano'
# To use debugger
# gem 'ruby-debug19'#, :require => 'ruby-debug'
I tried both paths - gems from github and just gems, but not luck...
EDIT:
Had to create passwords_controller.rb and users_controller.rb with the same syntax (names change respectively):
class UsersController < Devise::SessionsController
end
Now stuck at the very last step of example at http://refinerycms.com/guides/attaching-refinery-cms-as-part-of-a-larger-rails-31x-devise
Getting :
uninitialized constant Refinery::Role
When I try to run the server for the first time..
Full trace:
refinerycms-core (2.0.1) lib/refinery/application_controller.rb:53:in `just_installed?'
refinerycms-core (2.0.1) lib/refinery/application_controller.rb:73:in `refinery_user_required?'
activesupport (3.2.2) lib/active_support/callbacks.rb:418:in `_run__3443719849843969127__process_action__2929810487798718614__callbacks'
activesupport (3.2.2) lib/active_support/callbacks.rb:405:in `__run_callback'
activesupport (3.2.2) lib/active_support/callbacks.rb:385:in `_run_process_action_callbacks'
activesupport (3.2.2) lib/active_support/callbacks.rb:81:in `run_callbacks'
actionpack (3.2.2) lib/abstract_controller/callbacks.rb:17:in `process_action'
actionpack (3.2.2) lib/action_controller/metal/rescue.rb:29:in `process_action'
actionpack (3.2.2) lib/action_controller/metal/instrumentation.rb:30:in `block in process_action'
activesupport (3.2.2) lib/active_support/notifications.rb:123:in `block in instrument'
activesupport (3.2.2) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
activesupport (3.2.2) lib/active_support/notifications.rb:123:in `instrument'
actionpack (3.2.2) lib/action_controller/metal/instrumentation.rb:29:in `process_action'
actionpack (3.2.2) lib/action_controller/metal/params_wrapper.rb:205:in `process_action'
activerecord (3.2.2) lib/active_record/railties/controller_runtime.rb:18:in `process_action'
actionpack (3.2.2) lib/abstract_controller/base.rb:121:in `process'
actionpack (3.2.2) lib/abstract_controller/rendering.rb:45:in `process'
actionpack (3.2.2) lib/action_controller/metal.rb:203:in `dispatch'
actionpack (3.2.2) lib/action_controller/metal/rack_delegation.rb:14:in `dispatch'
actionpack (3.2.2) lib/action_controller/metal.rb:246:in `block in action'
actionpack (3.2.2) lib/action_dispatch/routing/route_set.rb:67:in `call'
actionpack (3.2.2) lib/action_dispatch/routing/route_set.rb:67:in `dispatch'
actionpack (3.2.2) lib/action_dispatch/routing/route_set.rb:30:in `call'
journey (1.0.3) lib/journey/router.rb:68:in `block in call'
journey (1.0.3) lib/journey/router.rb:56:in `each'
journey (1.0.3) lib/journey/router.rb:56:in `call'
actionpack (3.2.2) lib/action_dispatch/routing/route_set.rb:594:in `call'
railties (3.2.2) lib/rails/engine.rb:479:in `call'
railties (3.2.2) lib/rails/railtie/configurable.rb:30:in `method_missing'
journey (1.0.3) lib/journey/router.rb:68:in `block in call'
journey (1.0.3) lib/journey/router.rb:56:in `each'
journey (1.0.3) lib/journey/router.rb:56:in `call'
actionpack (3.2.2) lib/action_dispatch/routing/route_set.rb:594:in `call'
warden (1.1.1) lib/warden/manager.rb:35:in `block in call'
warden (1.1.1) lib/warden/manager.rb:34:in `catch'
warden (1.1.1) lib/warden/manager.rb:34:in `call'
actionpack (3.2.2) lib/action_dispatch/middleware/best_standards_support.rb:17:in `call'
rack (1.4.1) lib/rack/etag.rb:23:in `call'
rack (1.4.1) lib/rack/conditionalget.rb:25:in `call'
actionpack (3.2.2) lib/action_dispatch/middleware/head.rb:14:in `call'
actionpack (3.2.2) lib/action_dispatch/middleware/params_parser.rb:21:in `call'
actionpack (3.2.2) lib/action_dispatch/middleware/flash.rb:242:in `call'
rack (1.4.1) lib/rack/session/abstract/id.rb:205:in `context'
rack (1.4.1) lib/rack/session/abstract/id.rb:200:in `call'
actionpack (3.2.2) lib/action_dispatch/middleware/cookies.rb:338:in `call'
dragonfly (0.9.10) lib/dragonfly/cookie_monster.rb:9:in `call'
activerecord (3.2.2) lib/active_record/query_cache.rb:64:in `call'
activerecord (3.2.2) lib/active_record/connection_adapters/abstract/connection_pool.rb:443:in `call'
actionpack (3.2.2) lib/action_dispatch/middleware/callbacks.rb:28:in `block in call'
activesupport (3.2.2) lib/active_support/callbacks.rb:405:in `_run__3630594588424266621__call__617064894437263144__callbacks'
activesupport (3.2.2) lib/active_support/callbacks.rb:405:in `__run_callback'
activesupport (3.2.2) lib/active_support/callbacks.rb:385:in `_run_call_callbacks'
activesupport (3.2.2) lib/active_support/callbacks.rb:81:in `run_callbacks'
actionpack (3.2.2) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
dragonfly (0.9.10) lib/dragonfly/middleware.rb:13:in `call'
rack-cache (1.2) lib/rack/cache/context.rb:136:in `forward'
rack-cache (1.2) lib/rack/cache/context.rb:245:in `fetch'
rack-cache (1.2) lib/rack/cache/context.rb:185:in `lookup'
rack-cache (1.2) lib/rack/cache/context.rb:66:in `call!'
rack-cache (1.2) lib/rack/cache/context.rb:51:in `call'
actionpack (3.2.2) lib/action_dispatch/middleware/reloader.rb:65:in `call'
actionpack (3.2.2) lib/action_dispatch/middleware/remote_ip.rb:31:in `call'
actionpack (3.2.2) lib/action_dispatch/middleware/debug_exceptions.rb:16:in `call'
actionpack (3.2.2) lib/action_dispatch/middleware/show_exceptions.rb:56:in `call'
railties (3.2.2) lib/rails/rack/logger.rb:26:in `call_app'
railties (3.2.2) lib/rails/rack/logger.rb:16:in `call'
actionpack (3.2.2) lib/action_dispatch/middleware/request_id.rb:22:in `call'
rack (1.4.1) lib/rack/methodoverride.rb:21:in `call'
rack (1.4.1) lib/rack/runtime.rb:17:in `call'
activesupport (3.2.2) lib/active_support/cache/strategy/local_cache.rb:72:in `call'
rack (1.4.1) lib/rack/lock.rb:15:in `call'
actionpack (3.2.2) lib/action_dispatch/middleware/static.rb:61:in `call'
railties (3.2.2) lib/rails/engine.rb:479:in `call'
railties (3.2.2) lib/rails/application.rb:220:in `call'
rack (1.4.1) lib/rack/content_length.rb:14:in `call'
railties (3.2.2) lib/rails/rack/log_tailer.rb:14:in `call'
rack (1.4.1) lib/rack/handler/webrick.rb:59:in `service'
Thanks!

Try removing refinerycms-generators from your Gemfile. This gem is now obsolete as the generators were moved into refinerycms-core

Related

Paperclip::Errors::MissingRequiredValidatorError

Sorry, but i cant found solution for my situation
I have next code:
class Document < ActiveRecord::Base
has_attached_file :item,
content_type: { content_type: ["image/jpeg", "image/gif", "document/pdf"] }
end
gemfile:
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.1'
# Use sqlite3 as the database for Active Record
gem 'sqlite3'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.1.0'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby
# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.0'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0', group: :doc
gem 'bootstrap-sass'
gem 'haml'
gem "paperclip"
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'
# Use Unicorn as the app server
# gem 'unicorn'
# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development
shema.db:
ActiveRecord::Schema.define(version: 20151015113219) do
create_table "documents", force: :cascade do |t|
t.string "title"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.string "item_file_name"
t.string "item_content_type"
t.integer "item_file_size"
t.datetime "item_updated_at"
end
end
Documentscontroller:
class DocumentsController < ApplicationController
def index
#documents = Document.order('created_at')
end
def new
#document = Document.new
end
def create
#document = Document.new(document_params)
if #document.save
flash[:success] = "The file was added!"
redirect_to root_path
else
render 'new'
end
end
private
def document_params
params.require(:document).permit(:item, :title)
end
end
When i unload new file, displaying error: Paperclip::Errors::MissingRequiredValidatorError
Full trace:
paperclip (4.3.1) lib/paperclip/attachment.rb:399:in `ensure_required_validations!'
paperclip (4.3.1) lib/paperclip/attachment.rb:99:in `assign'
paperclip (4.3.1) lib/paperclip/has_attached_file.rb:66:in `block in define_setter'
activerecord (4.2.1) lib/active_record/attribute_assignment.rb:54:in `public_send'
activerecord (4.2.1) lib/active_record/attribute_assignment.rb:54:in `_assign_attribute'
activerecord (4.2.1) lib/active_record/attribute_assignment.rb:41:in `block in assign_attributes'
actionpack (4.2.1) lib/action_controller/metal/strong_parameters.rb:183:in `each_pair'
actionpack (4.2.1) lib/action_controller/metal/strong_parameters.rb:183:in `each_pair'
activerecord (4.2.1) lib/active_record/attribute_assignment.rb:35:in `assign_attributes'
activerecord (4.2.1) lib/active_record/core.rb:559:in `init_attributes'
activerecord (4.2.1) lib/active_record/core.rb:281:in `initialize'
activerecord (4.2.1) lib/active_record/inheritance.rb:61:in `new'
activerecord (4.2.1) lib/active_record/inheritance.rb:61:in `new'
actionpack (4.2.1) lib/action_controller/metal/implicit_render.rb:4:in `send_action'
actionpack (4.2.1) lib/abstract_controller/base.rb:198:in `process_action'
actionpack (4.2.1) lib/action_controller/metal/rendering.rb:10:in `process_action'
actionpack (4.2.1) lib/abstract_controller/callbacks.rb:20:in `block in process_action'
activesupport (4.2.1) lib/active_support/callbacks.rb:117:in `call'
activesupport (4.2.1) lib/active_support/callbacks.rb:117:in `call'
activesupport (4.2.1) lib/active_support/callbacks.rb:555:in `block (2 levels) in compile'
activesupport (4.2.1) lib/active_support/callbacks.rb:505:in `call'
activesupport (4.2.1) lib/active_support/callbacks.rb:505:in `call'
activesupport (4.2.1) lib/active_support/callbacks.rb:92:in `_run_callbacks'
activesupport (4.2.1) lib/active_support/callbacks.rb:776:in `_run_process_action_callbacks'
activesupport (4.2.1) lib/active_support/callbacks.rb:81:in `run_callbacks'
actionpack (4.2.1) lib/abstract_controller/callbacks.rb:19:in `process_action'
actionpack (4.2.1) lib/action_controller/metal/rescue.rb:29:in `process_action'
actionpack (4.2.1) lib/action_controller/metal/instrumentation.rb:32:in `block in process_action'
activesupport (4.2.1) lib/active_support/notifications.rb:164:in `block in instrument'
activesupport (4.2.1) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
activesupport (4.2.1) lib/active_support/notifications.rb:164:in `instrument'
actionpack (4.2.1) lib/action_controller/metal/instrumentation.rb:30:in `process_action'
actionpack (4.2.1) lib/action_controller/metal/params_wrapper.rb:250:in `process_action'
activerecord (4.2.1) lib/active_record/railties/controller_runtime.rb:18:in `process_action'
actionpack (4.2.1) lib/abstract_controller/base.rb:137:in `process'
actionview (4.2.1) lib/action_view/rendering.rb:30:in `process'
actionpack (4.2.1) lib/action_controller/metal.rb:196:in `dispatch'
actionpack (4.2.1) lib/action_controller/metal/rack_delegation.rb:13:in `dispatch'
actionpack (4.2.1) lib/action_controller/metal.rb:237:in `block in action'
actionpack (4.2.1) lib/action_dispatch/routing/route_set.rb:74:in `call'
actionpack (4.2.1) lib/action_dispatch/routing/route_set.rb:74:in `dispatch'
actionpack (4.2.1) lib/action_dispatch/routing/route_set.rb:43:in `serve'
actionpack (4.2.1) lib/action_dispatch/journey/router.rb:43:in `block in serve'
actionpack (4.2.1) lib/action_dispatch/journey/router.rb:30:in `each'
actionpack (4.2.1) lib/action_dispatch/journey/router.rb:30:in `serve'
actionpack (4.2.1) lib/action_dispatch/routing/route_set.rb:819:in `call'
rack (1.6.1) lib/rack/etag.rb:24:in `call'
rack (1.6.1) lib/rack/conditionalget.rb:38:in `call'
rack (1.6.1) lib/rack/head.rb:13:in `call'
actionpack (4.2.1) lib/action_dispatch/middleware/params_parser.rb:27:in `call'
actionpack (4.2.1) lib/action_dispatch/middleware/flash.rb:260:in `call'
rack (1.6.1) lib/rack/session/abstract/id.rb:225:in `context'
rack (1.6.1) lib/rack/session/abstract/id.rb:220:in `call'
actionpack (4.2.1) lib/action_dispatch/middleware/cookies.rb:560:in `call'
activerecord (4.2.1) lib/active_record/query_cache.rb:36:in `call'
activerecord (4.2.1) lib/active_record/connection_adapters/abstract/connection_pool.rb:649:in `call'
activerecord (4.2.1) lib/active_record/migration.rb:378:in `call'
actionpack (4.2.1) lib/action_dispatch/middleware/callbacks.rb:29:in `block in call'
activesupport (4.2.1) lib/active_support/callbacks.rb:88:in `call'
activesupport (4.2.1) lib/active_support/callbacks.rb:88:in `_run_callbacks'
activesupport (4.2.1) lib/active_support/callbacks.rb:776:in `_run_call_callbacks'
activesupport (4.2.1) lib/active_support/callbacks.rb:81:in `run_callbacks'
actionpack (4.2.1) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
actionpack (4.2.1) lib/action_dispatch/middleware/reloader.rb:73:in `call'
actionpack (4.2.1) lib/action_dispatch/middleware/remote_ip.rb:78:in `call'
actionpack (4.2.1) lib/action_dispatch/middleware/debug_exceptions.rb:17:in `call'
web-console (2.1.2) lib/web_console/middleware.rb:29:in `call'
actionpack (4.2.1) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
railties (4.2.1) lib/rails/rack/logger.rb:38:in `call_app'
railties (4.2.1) lib/rails/rack/logger.rb:20:in `block in call'
activesupport (4.2.1) lib/active_support/tagged_logging.rb:68:in `block in tagged'
activesupport (4.2.1) lib/active_support/tagged_logging.rb:26:in `tagged'
activesupport (4.2.1) lib/active_support/tagged_logging.rb:68:in `tagged'
railties (4.2.1) lib/rails/rack/logger.rb:20:in `call'
actionpack (4.2.1) lib/action_dispatch/middleware/request_id.rb:21:in `call'
rack (1.6.1) lib/rack/methodoverride.rb:22:in `call'
rack (1.6.1) lib/rack/runtime.rb:18:in `call'
activesupport (4.2.1) lib/active_support/cache/strategy/local_cache_middleware.rb:28:in `call'
rack (1.6.1) lib/rack/lock.rb:17:in `call'
actionpack (4.2.1) lib/action_dispatch/middleware/static.rb:113:in `call'
rack (1.6.1) lib/rack/sendfile.rb:113:in `call'
railties (4.2.1) lib/rails/engine.rb:518:in `call'
railties (4.2.1) lib/rails/application.rb:164:in `call'
rack (1.6.1) lib/rack/lock.rb:17:in `call'
rack (1.6.1) lib/rack/content_length.rb:15:in `call'
rack (1.6.1) lib/rack/handler/webrick.rb:89:in `service'
/usr/local/rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/webrick/httpserver.rb:138:in `service'
/usr/local/rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/webrick/httpserver.rb:94:in `run'
/usr/local/rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/webrick/server.rb:294:in `block in start_thread'
Form the paperclip 4.0 onwards validating the attachment content type is mandatory. So please add the validation logic in your model to work.
class Document < ActiveRecord::Base
has_attached_file :item
validates_attachment_content_type :item, :content_type => ["image/jpg", "image/jpeg", "image/png", "image/gif", "application/pdf"]
end
Specify a version lower than 4.0 for paperclip fixed for me, you can try that

ArgumentError in Rails::WelcomeController#index twitte bootstrap

I have been developing using rails 4 and ruby 1.9.3, I was using the twitter bootstrap tutorial from http://railscasts.com/episodes/328-twitter-bootstrap-basics and I am getting the following error now trying to load my app, can anyone help with this, I have tried variations of get "welcome/index" and root to: 'welcome#index' in my route.rb file.
Here are my welcome controller, framework trace, routes.rb and gem file:
Error message: ArgumentError in Rails::WelcomeController#index
/////Framework trace
actionpack (4.0.0) lib/abstract_controller/base.rb:89:in `initialize'
actionpack (4.0.0) lib/abstract_controller/base.rb:89:in `new'
actionpack (4.0.0) lib/abstract_controller/base.rb:89:in `action_methods'
actionpack (4.0.0) lib/action_controller/metal/hide_actions.rb:36:in `action_methods'
actionpack (4.0.0) lib/abstract_controller/url_for.rb:25:in `action_methods'
actionpack (4.0.0) lib/abstract_controller/base.rb:179:in `action_method?'
actionpack (4.0.0) lib/abstract_controller/base.rb:230:in `method_for_action'
actionpack (4.0.0) lib/action_controller/metal/hide_actions.rb:17:in `method_for_action'
actionpack (4.0.0) lib/action_controller/metal/implicit_render.rb:14:in `method_for_action'
actionpack (4.0.0) lib/abstract_controller/base.rb:130:in `process'
actionpack (4.0.0) lib/abstract_controller/rendering.rb:44:in `process'
actionpack (4.0.0) lib/action_controller/metal.rb:195:in `dispatch'
actionpack (4.0.0) lib/action_controller/metal/rack_delegation.rb:13:in `dispatch'
actionpack (4.0.0) lib/action_controller/metal.rb:231:in `block in action'
actionpack (4.0.0) lib/action_dispatch/routing/route_set.rb:80:in `call'
actionpack (4.0.0) lib/action_dispatch/routing/route_set.rb:80:in `dispatch'
actionpack (4.0.0) lib/action_dispatch/routing/route_set.rb:48:in `call'
actionpack (4.0.0) lib/action_dispatch/journey/router.rb:71:in `block in call'
actionpack (4.0.0) lib/action_dispatch/journey/router.rb:59:in `each'
actionpack (4.0.0) lib/action_dispatch/journey/router.rb:59:in `call'
actionpack (4.0.0) lib/action_dispatch/routing/route_set.rb:655:in `call'
warden (1.2.3) lib/warden/manager.rb:35:in `block in call'
warden (1.2.3) lib/warden/manager.rb:34:in `catch'
warden (1.2.3) lib/warden/manager.rb:34:in `call'
rack (1.5.2) lib/rack/etag.rb:23:in `call'
rack (1.5.2) lib/rack/conditionalget.rb:25:in `call'
rack (1.5.2) lib/rack/head.rb:11:in `call'
actionpack (4.0.0) lib/action_dispatch/middleware/params_parser.rb:27:in `call'
actionpack (4.0.0) lib/action_dispatch/middleware/flash.rb:241:in `call'
rack (1.5.2) lib/rack/session/abstract/id.rb:225:in `context'
rack (1.5.2) lib/rack/session/abstract/id.rb:220:in `call'
actionpack (4.0.0) lib/action_dispatch/middleware/cookies.rb:486:in `call'
activerecord (4.0.0) lib/active_record/query_cache.rb:36:in `call'
activerecord (4.0.0) lib/active_record/connection_adapters/abstract/connection_pool.rb:626:in `call'
activerecord (4.0.0) lib/active_record/migration.rb:369:in `call'
actionpack (4.0.0) lib/action_dispatch/middleware/callbacks.rb:29:in `block in call'
activesupport (4.0.0) lib/active_support/callbacks.rb:373:in `_run__159494264__call__callbacks'
activesupport (4.0.0) lib/active_support/callbacks.rb:80:in `run_callbacks'
actionpack (4.0.0) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
actionpack (4.0.0) lib/action_dispatch/middleware/reloader.rb:64:in `call'
actionpack (4.0.0) lib/action_dispatch/middleware/remote_ip.rb:76:in `call'
actionpack (4.0.0) lib/action_dispatch/middleware/debug_exceptions.rb:17:in `call'
actionpack (4.0.0) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
railties (4.0.0) lib/rails/rack/logger.rb:38:in `call_app'
railties (4.0.0) lib/rails/rack/logger.rb:21:in `block in call'
activesupport (4.0.0) lib/active_support/tagged_logging.rb:67:in `block in tagged'
activesupport (4.0.0) lib/active_support/tagged_logging.rb:25:in `tagged'
activesupport (4.0.0) lib/active_support/tagged_logging.rb:67:in `tagged'
railties (4.0.0) lib/rails/rack/logger.rb:21:in `call'
actionpack (4.0.0) lib/action_dispatch/middleware/request_id.rb:21:in `call'
rack (1.5.2) lib/rack/methodoverride.rb:21:in `call'
rack (1.5.2) lib/rack/runtime.rb:17:in `call'
activesupport (4.0.0) lib/active_support/cache/strategy/local_cache.rb:83:in `call'
rack (1.5.2) lib/rack/lock.rb:17:in `call'
actionpack (4.0.0) lib/action_dispatch/middleware/static.rb:64:in `call'
railties (4.0.0) lib/rails/engine.rb:511:in `call'
railties (4.0.0) lib/rails/application.rb:97:in `call'
rack (1.5.2) lib/rack/lock.rb:17:in `call'
rack (1.5.2) lib/rack/content_length.rb:14:in `call'
rack (1.5.2) lib/rack/handler/webrick.rb:60:in `service'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/webrick/httpserver.rb:138:in `service'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/webrick/httpserver.rb:94:in `run'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/webrick/server.rb:191:in `block in start_thread'
/////////Routes.rb
Myapp::Application.routes.draw do
devise_for :users
#get "welcome/index"
root to: 'welcome#index'
end
/////////Welcome controller
class WelcomeController < ApplicationController
def index
end
end
////////Gemfile
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.0.0'
# Use sqlite3 as the database for Active Record
gem 'sqlite3'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 4.0.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .js.coffee assets and views
gem 'coffee-rails', '~> 4.0.0'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
#gem 'therubyracer', platforms: :ruby
# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 1.2'
gem "paperclip", :git => "git://github.com/thoughtbot/paperclip.git"
gem 'protected_attributes'
gem 'will_paginate'
gem 'devise'
gem 'cancan'
gem 'less-rails'
gem 'twitter-bootstrap-rails'
gem 'therubyracer'
#gem 'libv8'
group :doc do
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', require: false
end
# group :assets do
# gem 'twitter-bootstrap-rails'
# end
# Use ActiveModel has_secure_password
# gem 'bcrypt-ruby', '~> 3.0.0'
# Use unicorn as the app server
# gem 'unicorn'
# Use Capistrano for deployment
# gem 'capistrano', group: :development
# Use debugger
# gem 'debugger', group: [:development, :test]
I don't have problems with twitter bootstrap, running in Ruby 2.0.
You can try in Ruby 2.0.

Rails - wrong number of arguments(1 for 0) for a newly generated Rails app?

I just setup a new rails app, and I uses rails generate controller Pages to create a blank page controller, then I added empty methods and views. I changed the route.rb to redirect to pages/:action, so it should display foo.html.erb for pages/foo. However, I have this error everytime I'm trying to access any of the page (pages/, pages/index, pages/course, etc.)
localhost:3000/pages/register (note: the actual Rails.root is different)
ArgumentError in PagesController#register
wrong number of arguments(1 for 0)
Rails.root: C:/railsapp
Application Trace | Framework Trace | Full Trace
actionpack (4.0.0) lib/abstract_controller/base.rb:89:in `initialize'
actionpack (4.0.0) lib/abstract_controller/base.rb:89:in `new'
actionpack (4.0.0) lib/abstract_controller/base.rb:89:in `action_methods'
actionpack (4.0.0) lib/action_controller/metal/hide_actions.rb:36:in `action_methods'
actionpack (4.0.0) lib/abstract_controller/url_for.rb:25:in `action_methods'
actionpack (4.0.0) lib/abstract_controller/base.rb:179:in `action_method?'
actionpack (4.0.0) lib/abstract_controller/base.rb:230:in `method_for_action'
actionpack (4.0.0) lib/action_controller/metal/hide_actions.rb:17:in `method_for_action'
actionpack (4.0.0) lib/action_controller/metal/implicit_render.rb:14:in `method_for_action'
actionpack (4.0.0) lib/abstract_controller/base.rb:130:in `process'
actionpack (4.0.0) lib/abstract_controller/rendering.rb:44:in `process'
actionpack (4.0.0) lib/action_controller/metal.rb:195:in `dispatch'
actionpack (4.0.0) lib/action_controller/metal/rack_delegation.rb:13:in `dispatch'
actionpack (4.0.0) lib/action_controller/metal.rb:231:in `block in action'
actionpack (4.0.0) lib/action_dispatch/routing/route_set.rb:80:in `call'
actionpack (4.0.0) lib/action_dispatch/routing/route_set.rb:80:in `dispatch'
actionpack (4.0.0) lib/action_dispatch/routing/route_set.rb:48:in `call'
actionpack (4.0.0) lib/action_dispatch/journey/router.rb:71:in `block in call'
actionpack (4.0.0) lib/action_dispatch/journey/router.rb:59:in `each'
actionpack (4.0.0) lib/action_dispatch/journey/router.rb:59:in `call'
actionpack (4.0.0) lib/action_dispatch/routing/route_set.rb:655:in `call'
rack (1.5.2) lib/rack/etag.rb:23:in `call'
rack (1.5.2) lib/rack/conditionalget.rb:25:in `call'
rack (1.5.2) lib/rack/head.rb:11:in `call'
actionpack (4.0.0) lib/action_dispatch/middleware/params_parser.rb:27:in `call'
actionpack (4.0.0) lib/action_dispatch/middleware/flash.rb:241:in `call'
rack (1.5.2) lib/rack/session/abstract/id.rb:225:in `context'
rack (1.5.2) lib/rack/session/abstract/id.rb:220:in `call'
actionpack (4.0.0) lib/action_dispatch/middleware/cookies.rb:486:in `call'
activerecord (4.0.0) lib/active_record/query_cache.rb:36:in `call'
activerecord (4.0.0) lib/active_record/connection_adapters/abstract/connection_pool.rb:626:in `call'
activerecord (4.0.0) lib/active_record/migration.rb:369:in `call'
actionpack (4.0.0) lib/action_dispatch/middleware/callbacks.rb:29:in `block in call'
activesupport (4.0.0) lib/active_support/callbacks.rb:373:in `_run__664391637__call__callbacks'
activesupport (4.0.0) lib/active_support/callbacks.rb:80:in `run_callbacks'
actionpack (4.0.0) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
actionpack (4.0.0) lib/action_dispatch/middleware/reloader.rb:64:in `call'
actionpack (4.0.0) lib/action_dispatch/middleware/remote_ip.rb:76:in `call'
actionpack (4.0.0) lib/action_dispatch/middleware/debug_exceptions.rb:17:in `call'
actionpack (4.0.0) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
railties (4.0.0) lib/rails/rack/logger.rb:38:in `call_app'
railties (4.0.0) lib/rails/rack/logger.rb:21:in `block in call'
activesupport (4.0.0) lib/active_support/tagged_logging.rb:67:in `block in tagged'
activesupport (4.0.0) lib/active_support/tagged_logging.rb:25:in `tagged'
activesupport (4.0.0) lib/active_support/tagged_logging.rb:67:in `tagged'
railties (4.0.0) lib/rails/rack/logger.rb:21:in `call'
actionpack (4.0.0) lib/action_dispatch/middleware/request_id.rb:21:in `call'
rack (1.5.2) lib/rack/methodoverride.rb:21:in `call'
rack (1.5.2) lib/rack/runtime.rb:17:in `call'
activesupport (4.0.0) lib/active_support/cache/strategy/local_cache.rb:83:in `call'
rack (1.5.2) lib/rack/lock.rb:17:in `call'
actionpack (4.0.0) lib/action_dispatch/middleware/static.rb:64:in `call'
railties (4.0.0) lib/rails/engine.rb:511:in `call'
railties (4.0.0) lib/rails/application.rb:97:in `call'
rack (1.5.2) lib/rack/lock.rb:17:in `call'
rack (1.5.2) lib/rack/content_length.rb:14:in `call'
rack (1.5.2) lib/rack/handler/webrick.rb:60:in `service'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/webrick/httpserver.rb:138:in `service'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/webrick/httpserver.rb:94:in `run'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/webrick/server.rb:191:in `block in start_thread'
Request
Parameters:
None
Toggle session dump
Toggle env dump
GATEWAY_INTERFACE: "CGI/1.1"
HTTP_ACCEPT: "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8"
HTTP_ACCEPT_ENCODING: "gzip,deflate,sdch"
HTTP_ACCEPT_LANGUAGE: "en-US,en;q=0.8"
REMOTE_ADDR: "127.0.0.1"
REMOTE_HOST: "127.0.0.1"
SERVER_NAME: "localhost"
SERVER_PROTOCOL: "HTTP/1.1"
Response
Headers:
None
pages_controller.rb
class PagesController < ApplicationController
def index
end
def course
end
def course_info
end
def register
end
def nav
end
end
route.rb
ChulaLounge::Application.routes.draw do
root :to => 'pages#nav'
get '/pages/:action', :controller => 'pages'
end
Gemfile
source 'https://rubygems.org'
ruby '1.9.3'
#ruby-gemset=mybook_rails_4_0
gem 'rails'
group :development do
gem 'sqlite3'
end
group :production do
gem 'rails_12factor'
gem 'pg'
end
gem 'haml'
gem 'sass-rails'
gem 'coffee-rails'
gem 'haml-rails'
gem 'uglifier'
gem 'jquery-rails'
gem 'turbolinks'
gem 'jbuilder'
gem "therubyracer"
gem "less-rails"
gem 'twitter-bootstrap-rails'
gem 'jquery-rails'
gem 'jquery-ui-rails'
gem 'designmodo-flatuipro-rails', '1.1.3.1'
gem 'formtastic'
gem 'protected_attributes'
gem 'angularjs-rails'
group :doc do
gem 'sdoc', require: false
end
I tried to recreate your error with the same style of routes and it worked fine. The only thing I can think of is maybe register is a super method in your class hierarchy and you've over-ridden it?

find_by_id still triggers ActiveRecord::RecordNotFound

When querying for an non-existing post in my controller via
#post = Post.find_by_id(params[:id])
I get ActiveRecord::RecordNotFound. But when I do the same in the rails console I get nil returned.
I also tried find_by_id! (note the exclamation point) that is supposed to trigger a 404, but it still just gives me ActiveRecord::RecordNotFound.
I found out that a gem could cause this kind of problem (see question: Rails Find_by_id raises exception), so my question is how do I figure out which gem that I use could cause the same problem?
This is my Gemfile
source 'https://rubygems.org'
gem 'rails', '3.2.7'
gem 'pg'
gem 'jquery-rails'
gem 'fancybox-rails', :git => 'https://github.com/sverigemeny/fancybox-rails'
gem 'bcrypt-ruby', '~> 3.0.0'
gem 'omniauth-twitter'
gem 'omniauth-facebook'
gem 'omniauth-google-oauth2'
gem 'validates_email_format_of', :git => 'git://github.com/alexdunae/validates_email_format_of.git'
gem 'cancan'
gem 'thin'
gem 'chronic'
gem 'simple_form'
gem 'twitter'
gem 'kaminari'
group :assets do
gem 'sass-rails'
gem 'compass-rails'
gem 'coffee-rails'
gem 'uglifier', '>= 1.0.3'
end
group :development do
gem 'quiet_assets'
gem 'faker'
end
I don't see how I can just disable one by one until I find the Gem that might causes this problem because I will most likely trigger many other errors due to Gem dependencies in the process.
Anyone have any idea of how I should go about this?
Update
Here is the full stacktrace:
ActiveRecord::RecordNotFound in PostsController#edit
Couldn't find Post with id=123202
activerecord (3.2.7) lib/active_record/relation/finder_methods.rb:341:in `find_one'
activerecord (3.2.7) lib/active_record/relation/finder_methods.rb:312:in `find_with_ids'
activerecord (3.2.7) lib/active_record/relation/finder_methods.rb:107:in `find'
activerecord (3.2.7) lib/active_record/querying.rb:5:in `find'
cancan (1.6.8) lib/cancan/model_adapters/abstract_adapter.rb:20:in `find'
cancan (1.6.8) lib/cancan/controller_resource.rb:114:in `find_resource'
cancan (1.6.8) lib/cancan/controller_resource.rb:68:in `load_resource_instance'
cancan (1.6.8) lib/cancan/controller_resource.rb:32:in `load_resource'
cancan (1.6.8) lib/cancan/controller_resource.rb:25:in `load_and_authorize_resource'
cancan (1.6.8) lib/cancan/controller_resource.rb:10:in `block in add_before_filter'
activesupport (3.2.7) lib/active_support/callbacks.rb:418:in `_run__4208450199150212965__process_action__1027836660135587880__callbacks'
activesupport (3.2.7) lib/active_support/callbacks.rb:405:in `__run_callback'
activesupport (3.2.7) lib/active_support/callbacks.rb:385:in `_run_process_action_callbacks'
activesupport (3.2.7) lib/active_support/callbacks.rb:81:in `run_callbacks'
actionpack (3.2.7) lib/abstract_controller/callbacks.rb:17:in `process_action'
actionpack (3.2.7) lib/action_controller/metal/rescue.rb:29:in `process_action'
actionpack (3.2.7) lib/action_controller/metal/instrumentation.rb:30:in `block in process_action'
activesupport (3.2.7) lib/active_support/notifications.rb:123:in `block in instrument'
activesupport (3.2.7) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
activesupport (3.2.7) lib/active_support/notifications.rb:123:in `instrument'
actionpack (3.2.7) lib/action_controller/metal/instrumentation.rb:29:in `process_action'
actionpack (3.2.7) lib/action_controller/metal/params_wrapper.rb:207:in `process_action'
activerecord (3.2.7) lib/active_record/railties/controller_runtime.rb:18:in `process_action'
actionpack (3.2.7) lib/abstract_controller/base.rb:121:in `process'
actionpack (3.2.7) lib/abstract_controller/rendering.rb:45:in `process'
actionpack (3.2.7) lib/action_controller/metal.rb:203:in `dispatch'
actionpack (3.2.7) lib/action_controller/metal/rack_delegation.rb:14:in `dispatch'
actionpack (3.2.7) lib/action_controller/metal.rb:246:in `block in action'
actionpack (3.2.7) lib/action_dispatch/routing/route_set.rb:73:in `call'
actionpack (3.2.7) lib/action_dispatch/routing/route_set.rb:73:in `dispatch'
actionpack (3.2.7) lib/action_dispatch/routing/route_set.rb:36:in `call'
journey (1.0.4) lib/journey/router.rb:68:in `block in call'
journey (1.0.4) lib/journey/router.rb:56:in `each'
journey (1.0.4) lib/journey/router.rb:56:in `call'
actionpack (3.2.7) lib/action_dispatch/routing/route_set.rb:600:in `call'
omniauth (1.1.1) lib/omniauth/strategy.rb:177:in `call!'
omniauth (1.1.1) lib/omniauth/strategy.rb:157:in `call'
omniauth (1.1.1) lib/omniauth/strategy.rb:177:in `call!'
omniauth (1.1.1) lib/omniauth/strategy.rb:157:in `call'
omniauth (1.1.1) lib/omniauth/strategy.rb:177:in `call!'
omniauth (1.1.1) lib/omniauth/strategy.rb:157:in `call'
omniauth (1.1.1) lib/omniauth/builder.rb:48:in `call'
actionpack (3.2.7) lib/action_dispatch/middleware/best_standards_support.rb:17:in `call'
rack (1.4.3) lib/rack/etag.rb:23:in `call'
rack (1.4.3) lib/rack/conditionalget.rb:25:in `call'
actionpack (3.2.7) lib/action_dispatch/middleware/head.rb:14:in `call'
actionpack (3.2.7) lib/action_dispatch/middleware/params_parser.rb:21:in `call'
actionpack (3.2.7) lib/action_dispatch/middleware/flash.rb:242:in `call'
rack (1.4.3) lib/rack/session/abstract/id.rb:210:in `context'
rack (1.4.3) lib/rack/session/abstract/id.rb:205:in `call'
actionpack (3.2.7) lib/action_dispatch/middleware/cookies.rb:338:in `call'
activerecord (3.2.7) lib/active_record/query_cache.rb:64:in `call'
activerecord (3.2.7) lib/active_record/connection_adapters/abstract/connection_pool.rb:473:in `call'
actionpack (3.2.7) lib/action_dispatch/middleware/callbacks.rb:28:in `block in call'
activesupport (3.2.7) lib/active_support/callbacks.rb:405:in `_run__503554315877740465__call__403817388267166975__callbacks'
activesupport (3.2.7) lib/active_support/callbacks.rb:405:in `__run_callback'
activesupport (3.2.7) lib/active_support/callbacks.rb:385:in `_run_call_callbacks'
activesupport (3.2.7) lib/active_support/callbacks.rb:81:in `run_callbacks'
actionpack (3.2.7) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
actionpack (3.2.7) lib/action_dispatch/middleware/reloader.rb:65:in `call'
actionpack (3.2.7) lib/action_dispatch/middleware/remote_ip.rb:31:in `call'
actionpack (3.2.7) lib/action_dispatch/middleware/debug_exceptions.rb:16:in `call'
actionpack (3.2.7) lib/action_dispatch/middleware/show_exceptions.rb:56:in `call'
railties (3.2.7) lib/rails/rack/logger.rb:26:in `call_app'
railties (3.2.7) lib/rails/rack/logger.rb:16:in `call'
quiet_assets (1.0.1) lib/quiet_assets.rb:20:in `call_with_quiet_assets'
actionpack (3.2.7) lib/action_dispatch/middleware/request_id.rb:22:in `call'
rack (1.4.3) lib/rack/methodoverride.rb:21:in `call'
rack (1.4.3) lib/rack/runtime.rb:17:in `call'
activesupport (3.2.7) lib/active_support/cache/strategy/local_cache.rb:72:in `call'
rack (1.4.3) lib/rack/lock.rb:15:in `call'
actionpack (3.2.7) lib/action_dispatch/middleware/static.rb:62:in `call'
railties (3.2.7) lib/rails/engine.rb:479:in `call'
railties (3.2.7) lib/rails/application.rb:220:in `call'
rack (1.4.3) lib/rack/content_length.rb:14:in `call'
railties (3.2.7) lib/rails/rack/log_tailer.rb:17:in `call'
thin (1.5.0) lib/thin/connection.rb:81:in `block in pre_process'
thin (1.5.0) lib/thin/connection.rb:79:in `catch'
thin (1.5.0) lib/thin/connection.rb:79:in `pre_process'
thin (1.5.0) lib/thin/connection.rb:54:in `process'
thin (1.5.0) lib/thin/connection.rb:39:in `receive_data'
eventmachine (1.0.0) lib/eventmachine.rb:187:in `run_machine'
eventmachine (1.0.0) lib/eventmachine.rb:187:in `run'
thin (1.5.0) lib/thin/backends/base.rb:63:in `start'
thin (1.5.0) lib/thin/server.rb:159:in `start'
rack (1.4.3) lib/rack/handler/thin.rb:13:in `run'
rack (1.4.3) lib/rack/server.rb:268:in `start'
railties (3.2.7) lib/rails/commands/server.rb:70:in `start'
railties (3.2.7) lib/rails/commands.rb:55:in `block in <top (required)>'
railties (3.2.7) lib/rails/commands.rb:50:in `tap'
railties (3.2.7) lib/rails/commands.rb:50:in `<top (required)>'
script/rails:6:in `require'
script/rails:6:in `<main>'
As drewinglis pointed out, this is caused by cancan.
Cancan loads the post to determine whether the user has authorisation to perform whatever action on it. If the post is not found, it will respond with a 404, ActiveRecord::RecordNotFound.
Here, Ryan goes into the reasoning behind this a little: https://github.com/ryanb/cancan/issues/43 he also suggests rescuing from the 404 if that's not the behaviour you require.
drwesinglis and cheeseweasel are correct, this was caused by CanCan. I was not able to get the solutions from the post https://github.com/ryanb/cancan/issues/43 to work, so I removed load_and_authorize_resource from my controllers and I am now checking manually if the user is authorized to complete the action.
My controller now looks like this:
#post = Post.find_by_id(params[:id])
if #post
if can? :update, #post
...
else
flash[:error] = 'You are not authorized to access this post.'
redirect_to root_url
end
else
flash[:error] = 'This post doesn\'t exist.'
redirect_to root_url
end
I will update my code later in the development cycle to redirect to a nicer 404 page, but for now I just show the messages.

Heroku NoMethodError - Paperclip

Edit2~
Hi All,
I solved my previous new error by changing my model file according to this. I don't know why but it solved it. I now have this error to deal with. : |
There is no key? method in my controller. Do I need to include it? If so, how?
NoMethodError in ProductPhotosController#index
undefined method `key?' for nil:NilClass
Rails.root: /Users/cj3kim/Desktop/rails_projects/chocosite
Here is the full trace:
actionpack (3.2.2) lib/action_controller/metal/hide_actions.rb:36:in `visible_action?'
actionpack (3.2.2) lib/action_controller/metal/hide_actions.rb:18:in `method_for_action'
actionpack (3.2.2) lib/action_controller/metal/implicit_render.rb:14:in `method_for_action'
actionpack (3.2.2) lib/action_controller/metal/compatibility.rb:61:in `method_for_action'
actionpack (3.2.2) lib/abstract_controller/base.rb:115:in `process'
actionpack (3.2.2) lib/abstract_controller/rendering.rb:45:in `process'
actionpack (3.2.2) lib/action_controller/metal.rb:203:in `dispatch'
actionpack (3.2.2) lib/action_controller/metal/rack_delegation.rb:14:in `dispatch'
actionpack (3.2.2) lib/action_controller/metal.rb:246:in `block in action'
actionpack (3.2.2) lib/action_dispatch/routing/route_set.rb:67:in `call'
actionpack (3.2.2) lib/action_dispatch/routing/route_set.rb:67:in `dispatch'
actionpack (3.2.2) lib/action_dispatch/routing/route_set.rb:30:in `call'
journey (1.0.3) lib/journey/router.rb:68:in `block in call'
journey (1.0.3) lib/journey/router.rb:56:in `each'
journey (1.0.3) lib/journey/router.rb:56:in `call'
actionpack (3.2.2) lib/action_dispatch/routing/route_set.rb:594:in `call'
actionpack (3.2.2) lib/action_dispatch/middleware/best_standards_support.rb:17:in `call'
rack (1.4.1) lib/rack/etag.rb:23:in `call'
rack (1.4.1) lib/rack/conditionalget.rb:25:in `call'
actionpack (3.2.2) lib/action_dispatch/middleware/head.rb:14:in `call'
actionpack (3.2.2) lib/action_dispatch/middleware/params_parser.rb:21:in `call'
actionpack (3.2.2) lib/action_dispatch/middleware/flash.rb:242:in `call'
rack (1.4.1) lib/rack/session/abstract/id.rb:205:in `context'
rack (1.4.1) lib/rack/session/abstract/id.rb:200:in `call'
actionpack (3.2.2) lib/action_dispatch/middleware/cookies.rb:338:in `call'
activerecord (3.2.2) lib/active_record/query_cache.rb:64:in `call'
activerecord (3.2.2) lib/active_record/connection_adapters/abstract/connection_pool.rb:443:in `call'
actionpack (3.2.2) lib/action_dispatch/middleware/callbacks.rb:28:in `block in call'
activesupport (3.2.2) lib/active_support/callbacks.rb:405:in `_run__3068104272435367366__call__4006997629250885704__callbacks'
activesupport (3.2.2) lib/active_support/callbacks.rb:405:in `__run_callback'
activesupport (3.2.2) lib/active_support/callbacks.rb:385:in `_run_call_callbacks'
activesupport (3.2.2) lib/active_support/callbacks.rb:81:in `run_callbacks'
actionpack (3.2.2) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
actionpack (3.2.2) lib/action_dispatch/middleware/reloader.rb:65:in `call'
actionpack (3.2.2) lib/action_dispatch/middleware/remote_ip.rb:31:in `call'
actionpack (3.2.2) lib/action_dispatch/middleware/debug_exceptions.rb:16:in `call'
actionpack (3.2.2) lib/action_dispatch/middleware/show_exceptions.rb:56:in `call'
railties (3.2.2) lib/rails/rack/logger.rb:26:in `call_app'
railties (3.2.2) lib/rails/rack/logger.rb:16:in `call'
actionpack (3.2.2) lib/action_dispatch/middleware/request_id.rb:22:in `call'
rack (1.4.1) lib/rack/methodoverride.rb:21:in `call'
rack (1.4.1) lib/rack/runtime.rb:17:in `call'
activesupport (3.2.2) lib/active_support/cache/strategy/local_cache.rb:72:in `call'
rack (1.4.1) lib/rack/lock.rb:15:in `call'
actionpack (3.2.2) lib/action_dispatch/middleware/static.rb:61:in `call'
railties (3.2.2) lib/rails/engine.rb:479:in `call'
railties (3.2.2) lib/rails/application.rb:220:in `call'
rack (1.4.1) lib/rack/content_length.rb:14:in `call'
railties (3.2.2) lib/rails/rack/log_tailer.rb:14:in `call'
rack (1.4.1) lib/rack/handler/webrick.rb:59:in `service'
/Users/cj3kim/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/webrick/httpserver.rb:138:in `service'
/Users/cj3kim/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/webrick/httpserver.rb:94:in `run'
/Users/cj3kimactionpack (3.2.2) lib/action_controller/metal/hide_actions.rb:36:in `visible_action?'
actionpack (3.2.2) lib/action_controller/metal/hide_actions.rb:18:in `method_for_action'
actionpack (3.2.2) lib/action_controller/metal/implicit_render.rb:14:in `method_for_action'
actionpack (3.2.2) lib/action_controller/metal/compatibility.rb:61:in `method_for_action'
actionpack (3.2.2) lib/abstract_controller/base.rb:115:in `process'
actionpack (3.2.2) lib/abstract_controller/rendering.rb:45:in `process'
actionpack (3.2.2) lib/action_controller/metal.rb:203:in `dispatch'
actionpack (3.2.2) lib/action_controller/metal/rack_delegation.rb:14:in `dispatch'
actionpack (3.2.2) lib/action_controller/metal.rb:246:in `block in action'
actionpack (3.2.2) lib/action_dispatch/routing/route_set.rb:67:in `call'
actionpack (3.2.2) lib/action_dispatch/routing/route_set.rb:67:in `dispatch'
actionpack (3.2.2) lib/action_dispatch/routing/route_set.rb:30:in `call'
journey (1.0.3) lib/journey/router.rb:68:in `block in call'
journey (1.0.3) lib/journey/router.rb:56:in `each'
journey (1.0.3) lib/journey/router.rb:56:in `call'
actionpack (3.2.2) lib/action_dispatch/routing/route_set.rb:594:in `call'
actionpack (3.2.2) lib/action_dispatch/middleware/best_standards_support.rb:17:in `call'
rack (1.4.1) lib/rack/etag.rb:23:in `call'
rack (1.4.1) lib/rack/conditionalget.rb:25:in `call'
actionpack (3.2.2) lib/action_dispatch/middleware/head.rb:14:in `call'
actionpack (3.2.2) lib/action_dispatch/middleware/params_parser.rb:21:in `call'
actionpack (3.2.2) lib/action_dispatch/middleware/flash.rb:242:in `call'
rack (1.4.1) lib/rack/session/abstract/id.rb:205:in `context'
rack (1.4.1) lib/rack/session/abstract/id.rb:200:in `call'
actionpack (3.2.2) lib/action_dispatch/middleware/cookies.rb:338:in `call'
activerecord (3.2.2) lib/active_record/query_cache.rb:64:in `call'
activerecord (3.2.2) lib/active_record/connection_adapters/abstract/connection_pool.rb:443:in `call'
actionpack (3.2.2) lib/action_dispatch/middleware/callbacks.rb:28:in `block in call'
activesupport (3.2.2) lib/active_support/callbacks.rb:405:in `_run__3068104272435367366__call__4006997629250885704__callbacks'
activesupport (3.2.2) lib/active_support/callbacks.rb:405:in `__run_callback'
activesupport (3.2.2) lib/active_support/callbacks.rb:385:in `_run_call_callbacks'
activesupport (3.2.2) lib/active_support/callbacks.rb:81:in `run_callbacks'
actionpack (3.2.2) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
actionpack (3.2.2) lib/action_dispatch/middleware/reloader.rb:65:in `call'
actionpack (3.2.2) lib/action_dispatch/middleware/remote_ip.rb:31:in `call'
actionpack (3.2.2) lib/action_dispatch/middleware/debug_exceptions.rb:16:in `call'
actionpack (3.2.2) lib/action_dispatch/middleware/show_exceptions.rb:56:in `call'
railties (3.2.2) lib/rails/rack/logger.rb:26:in `call_app'
railties (3.2.2) lib/rails/rack/logger.rb:16:in `call'
actionpack (3.2.2) lib/action_dispatch/middleware/request_id.rb:22:in `call'
rack (1.4.1) lib/rack/methodoverride.rb:21:in `call'
rack (1.4.1) lib/rack/runtime.rb:17:in `call'
activesupport (3.2.2) lib/active_support/cache/strategy/local_cache.rb:72:in `call'
rack (1.4.1) lib/rack/lock.rb:15:in `call'
actionpack (3.2.2) lib/action_dispatch/middleware/static.rb:61:in `call'
railties (3.2.2) lib/rails/engine.rb:479:in `call'
railties (3.2.2) lib/rails/application.rb:220:in `call'
rack (1.4.1) lib/rack/content_length.rb:14:in `call'
railties (3.2.2) lib/rails/rack/log_tailer.rb:14:in `call'
rack (1.4.1) lib/rack/handler/webrick.rb:59:in `service'
/Users/cj3kim/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/webrick/httpserver.rb:138:in `service'
/Users/cj3kim/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/webrick/httpserver.rb:94:in `run'
/Users/cj3kim/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/webrick/server.rb:191:in `block in start_thread'/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/webrick/server.rb:191:in `block in start_thread'
Here is my controller:
1 class ProductPhotosController < ApplicationController
2 # GET /product_photos
3 # GET /product_photos.json
4 def index
5 #product_photos = ProductPhoto.all
6
7 respond_to do |format|
8 format.html # index.html.erb
9 format.json { render json: #product_photos }
10 end
11 end
Here is my model:
1 class ProductPhoto < ActiveRecord::Base
2 has_attached_file :image,
3 :style => {:small => "150x150"},
4 :storage => :s3,
5 :s3_credentials => "#{RAILS_ROOT}/config/s3.yml",
6 :path => "chocosite/:attachment/:style/:id.:extension"
7 end
End edit
Edit~
Heroku Load Error - Paperclip
The problem was a syntax error I found in my model. I have a new problem now
What I did:
This problem occurred on the local host with sqlite3 as db. I logged onto the s3 module and uploaded all the relevant folders that were once in 'public/system/images/000/000/' to the folder 'images' in the bucket choco_photos on s3. I also changed the URL and PATH to reflect it but I'm pretty sure I did something wrong.
Do the PATH AND URL file reflect where the image is stored and accessed on S3?
I will mention I am still confused about the configurations even after watching the railscast on paperclip. I checked the docs AWS recommended but it didn't help. To be specific, I was confused by this statement:
# File 'lib/paperclip/storage/s3.rb', line 203
def s3_object style_name = default_style
s3_bucket.objects[path(style_name).sub(%r{^/},'')]
end
Any and all help is appreciated.
More info:
LoadError in Product_photos#index
Showing /Users/cj3kim/Desktop/rails_projects/chocosite/app/views/product_photos/index.html.erb where line #4 raised:
cannot load such file -- aws-sdk (You may need to install the aws-sdk gem)
Extracted source (around line #4):
1: <div id="container_product_photos">
2: <% #product_photos.each do |photo| %>
3: <div class="product_box" >
4: /*#<%= link_to image_tag(photo.image.url(:small)), product_photo_path(photo) %>*/
5: <p class='description'><%= photo.Name %> </p>
6: </div>
7: <% end %>
Here is my model file:
1 class ProductPhoto < ActiveRecord::Base
2 has_attached_file :image,
3 :storage => :s3,
4 :s3_credentials => {
5 :access_key_id => ENV['Access Key'],
6 :secret_access_key => ENV['Secret Key']
7 },
8 :bucket => ENV['choco_photos'],
9 :style => {
10 :small => "150x150"
11 },
12 :url => "/images/:id/:style/:basename.:extension",
13 :path => "/images/:id/:style/:basename.:extension"
14 end
~
Here is my gemfile:
12 group :production do
13 gem 'pg'
14 end
15
16 gem 'bootstrap-sass', '2.0.0'
17 gem 'paperclip', '~> 3.0'
18 gem 'aws-sdk', '~> 1.3.4'
End of Edit
For question 1: Heroku runs 1.9.2 on the Cedar stack, which you are on based on your app's URL. I believe the 1.9.1 is just a directory and does not actually related to the version ... I get the same "mismatch" between 1.9.1 in a folder name and my system actually running 1.9.2 or 1.9.3 (and I only run 1.9.2 or 1.9.3 via RVM).
You can verify the Heroku version by opening a Rails console on heroku ...
Open Terminal/Console
Navigate to your project directory
Type: heroku run console (this assumes you've installed the heroku gem or CLI tools)
Once the console loads, type: RUBY_VERSION (you should see either 1.9.2 or 1.9.3 output)
For the question 2: I had to alter how I had paperclip in my Gemfile. I use this and it works on Cedar:
gem 'paperclip', "~> 3.0"
gem "aws-sdk"
And in my related model:
has_attached_file :photo,
:storage => :s3,
:s3_credentials => "#{Rails.root}/config/s3.yml",
:styles => {
:large => "600x480",
:medium => "330x230",
:small => "210x150",
:thumb => "90x90"
},
:path => 'images/products/:style/:filename'
And in my s3.yml file:
development:
access_key_id: MYKEY
secret_access_key: MYSUPERSECRETACCESSKEY
bucket: bucketname
Hope that helps!

Resources