Git Product home page Git Product logo

shopify_app's Introduction

Shopify App

Version Build Status

This gem builds Rails applications that can be embedded in the Shopify Admin.

Introduction | Requirements | Usage | Documentation | Contributing | License

Introduction

This gem includes a Rails engine, generators, modules, and mixins that help create Rails applications that work with Shopify APIs. The Shopify App Rails engine provides all the code required to implement OAuth with Shopify. The default Shopify App generator builds an app that can be embedded in the Shopify Admin and secures it with session tokens.

Requirements

To become a Shopify app developer, you will need a Shopify Partners account. Explore the Shopify dev docs to learn more about building Shopify apps.

This gem requires that you have the following credentials:

Usage

  1. To get started, create a new Rails app:
rails new my_shopify_app
  1. Add the Shopify App gem to the app's Gemfile:
bundle add shopify_app
  1. You will need to provide several environment variables to the app. There are a variety of way of doing this, but for a development environment we recommended the dotenv-rails gem. Create a .env file in the root of your Rails app to specify the full host and Shopify API credentials:
HOST=http://localhost:3000
SHOPIFY_API_KEY=<Your Shopify API key>
SHOPIFY_API_SECRET=<Your Shopify API secret>
  1. Run the default Shopify App generator to create an app that can be embedded in the Shopify Admin:
rails generate shopify_app
  1. Run a migration to create the necessary tables in your database:
rails db:migrate
  1. Run the app:
rails server
  1. Within Shopify Partners, navigate to your App, then App Setup, and configure the URLs, e.g.:
  1. Install the app by visiting the server's URL (e.g. http://localhost:3000) and specifying the subdomain of the shop where you want it to be installed to.

  2. After the app is installed, you're redirected to the embedded app.

This app implements OAuth 2.0 with Shopify to authenticate requests made to Shopify APIs. By default, this app is configured to use session tokens to authenticate merchants when embedded in the Shopify Admin.

See Generators for a complete list of generators available to Shopify App.

Documentation

You can find documentation on gem usage, concepts, mixins, installation, and more in /docs.

  • Start with the Generators document to learn more about the generators this gem offers.
  • Check out the Changelog for notes on the latest gem releases.
  • See Troubleshooting for tips on common issues.
  • If you are looking to upgrade your Shopify App version to a new major release, see Upgrading for important notes on breaking changes.

Overview

Quickstart

Troubleshooting

Upgrading

Shopify App

Engine

Mounting the Shopify App Rails Engine provides the following routes. These routes are configured to help install your application on shops and implement OAuth.

Verb Route Action
GET /login Login
POST /login Login
GET /auth/shopify/callback OAuth redirect URI
GET /logout Logout
POST /webhooks/:type Webhook callback

These routes are configurable. See the more detailed Engine documentation to learn how you can customize the login URL or mount the Shopify App Rails engine at nested routes.

To learn more about how this gem authenticates with Shopify, see Authentication.

New embedded app authorization strategy (Token Exchange)

Tip

If you are building an embedded app, we strongly recommend using Shopify managed installation with token exchange instead of the legacy authorization code grant flow.

We've introduced a new installation and authorization strategy for embedded apps that eliminates the redirects that were previously necessary. It replaces the existing installation and authorization code grant flow.

This is achieved by using Shopify managed installation to handle automatic app installations and scope updates, while utilizing token exchange to retrieve an access token for authenticated API access.

Enabling this new strategy in your app
  1. Enable Shopify managed installation by configuring your scopes through the Shopify CLI.
  2. Enable the new auth strategy in your app's ShopifyApp configuration file.
# config/initializers/shopify_app.rb
ShopifyApp.configure do |config|
  #.....
  config.embedded_app = true
  config.new_embedded_auth_strategy = true

  # If your app is configured to use online sessions, you can enable session expiry date check so a new access token
  # is fetched automatically when the session expires.
  # See expiry date check docs: https://github.com/Shopify/shopify_app/blob/main/docs/shopify_app/sessions.md#expiry-date
  config.check_session_expiry_date = true
  ...
end
  1. Handle special callback logic. If your app has overridden the OAuth CallbackController to run special tasks post authorization, you'll need to create and configure a custom PostAuthenticateTasks class to run these tasks after the token exchange. The original OAuth CallbackController will not be triggered anymore. See Post Authenticate Tasks documentation for more information.
  2. Enjoy a smoother and faster app installation process.

API Versioning

Shopify's API is versioned. With Shopify App v1.11.0, the included Shopify API gem allows developers to specify and update the Shopify API version they want their app or service to use. The Shopify API gem also surfaces warnings to Rails apps about deprecated endpoints, GraphQL fields and more.

See the Shopify API gem README for more information.

shopify_app's People

Contributors

adfaris avatar alexaitken avatar alexcoco avatar andyw8 avatar ashmaroli avatar celsodantas avatar dependabot[bot] avatar elias-rumley avatar gmalette avatar gonzaloriestra avatar hammadk avatar henrytao-me avatar jesalerno84 avatar kevinhughes27 avatar klenotiw avatar lizkenyon avatar meulmees avatar mkevinosullivan avatar mllemango avatar nabeelahsen avatar nelsonwittwer avatar nwtn avatar paulomarg avatar ragalie avatar rezaansyed avatar slucaskim avatar swalkinshaw avatar translation-platform avatar tylerball avatar zzooeeyy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

shopify_app's Issues

Processing by HomeController#index undefined method `site'

Trying to get the server up and running. I managed to start it up, enter in my site, authenticate but then the app crashed with the followng stack. Now whenever I start the site up I get this.

Started GET "/" for 127.0.0.1 at 2014-05-06 12:12:47 +1000
Processing by HomeController#index as HTML
Completed 500 Internal Server Error in 18ms

NoMethodError (undefined method `site' for "#<ShopifyAPI::Session:0x007f771a20f808>":String):
  shopify_api (3.2.1) lib/shopify_api/resources/base.rb:52:in `activate_session'
  shopify_app (4.4.4) lib/shopify_app/login_protection.rb:12:in `shopify_session'
  activesupport (4.1.0) lib/active_support/callbacks.rb:424:in `block in make_lambda'
  activesupport (4.1.0) lib/active_support/callbacks.rb:281:in `call'
  activesupport (4.1.0) lib/active_support/callbacks.rb:281:in `block in halting_and_conditional'
  ...

ruby -v: 2.1.0
rails -v: 4.1.0
os: ubuntu

Also, I try removing the app from my shop, restarting and the hitting http://localhost:3000/login?shop=my_shop_url directly but still get the same error.

After some long searching I believe this is related to fix #90 with a pull request pending

Error while doing ShopifyAPI::RecurringApplicationCharge.create()

Hi

I am getting this error while creating recurring payment and while calling ShopifyAPI::RecurringApplicationCharge.current

undefined method `path' for nil:NilClass

My error is:
undefined method `path' for nil:NilClass

Rails.root: /Users/admin/Sites/projects/rails3/MyApp
Application Trace | Framework Trace | Full Trace

app/controllers/application_controller.rb:18:in create_merchant_payment'
app/controllers/sessions_controller.rb:21:inshow'

My code:
def create_merchant_payment
charge = ShopifyAPI::RecurringApplicationCharge.create(:name => "Basic plan", :price => 10.0, :return_url => "http://localhost:3000/charges/confirm", :test => true)
redirect_to charge.confirmation_url
end

Any idea?

Awaiting for your reply

Thanks
Ranjith

@Gissues:{"order":42.85714285714285,"status":"backlog"}

Issues w/ Shopify_app using Resque

I continue to receive undefined method `path' for nil:NilClass at the below line.

ShopifyAPI::Webhook.create(:address => "#{url}/#{wh.address}/webhook.json", :format => "#{wh.format}", :topic => "#{wh.topic}", :access_token => Shop.find(shop_id).access_token)

Any thoughts?

Can't run the shopify_app in rails 4.0.0 and 4.0.3

$ rails new my_shopify_app
$ cd my_shopify_app

$ echo "gem 'shopify_app'" >> Gemfile
$ bundle install

$ rails generate shopify_app your_app_api_key your_app_secret
$ rails server

After I finish type this, it comes up with the errors:

/Users/enriquesalceda/.rvm/gems/ruby-2.1.0@myapp/gems/railties-4.0.0/lib/rails/railtie/configuration.rb:95:in method_missing': undefined methodshopify' for #Rails::Application::Configuration:0x00000101d4b1b8 (NoMethodError)
from /Users/enriquesalceda/workspace/myapp/my_shopify_app4/config/application.rb:13:in <class:Application>' from /Users/enriquesalceda/workspace/myapp/my_shopify_app4/config/application.rb:10:inmodule:MyShopifyApp4'
from /Users/enriquesalceda/workspace/myapp/my_shopify_app4/config/application.rb:9:in <top (required)>' from /Users/enriquesalceda/.rvm/gems/ruby-2.1.0@myapp/gems/railties-4.0.0/lib/rails/commands.rb:76:inrequire'
from /Users/enriquesalceda/.rvm/gems/ruby-2.1.0@myapp/gems/railties-4.0.0/lib/rails/commands.rb:76:in block in <top (required)>' from /Users/enriquesalceda/.rvm/gems/ruby-2.1.0@myapp/gems/railties-4.0.0/lib/rails/commands.rb:73:intap'
from /Users/enriquesalceda/.rvm/gems/ruby-2.1.0@myapp/gems/railties-4.0.0/lib/rails/commands.rb:73:in <top (required)>' from bin/rails:4:inrequire'
from bin/rails:4:in `

'

Could anyone tell me how to solve it?

.

.

LoginController should be made restful

Currently the generated login controller litters routes.rb with custom routes that are not necissary if the controller acts as RESTful controller on a shopify session.

More uses of new hash syntax. Breaks in Ruby 1.8

        Called from: /Library/Ruby/Gems/1.8/gems/actionpack-3.2.10/lib/action_dispatch/middleware/session/abstract_store.rb:28:in `initialize'.

[WARNING] Could not load generator "generators/shopify_app/shopify_app_generator". Error: /Users/meekohi/.bundler/ruby/1.8/shopify_app-8af04a9d5e2e/lib/generators/shopify_app/shopify_app_generator.rb:64: odd number list for Hash
...\n  #{routing_code}", { after: sentinel, verbose: false }
                              ^
/Users/meekohi/.bundler/ruby/1.8/shopify_app-8af04a9d5e2e/lib/generators/shopify_app/shopify_app_generator.rb:64: syntax error, unexpected ':', expecting '}'
...\n  #{routing_code}", { after: sentinel, verbose: false }
                              ^
/Users/meekohi/.bundler/ruby/1.8/shopify_app-8af04a9d5e2e/lib/generators/shopify_app/shopify_app_generator.rb:64: syntax error, unexpected ':', expecting '='
...", { after: sentinel, verbose: false }
                              ^.
/Library/Ruby/Gems/1.8/gems/activesupport-3.2.10/lib/active_support/dependencies.rb:251:in `require'
/Library/Ruby/Gems/1.8/gems/activesupport-3.2.10/lib/active_support/dependencies.rb:251:in `require'
/Library/Ruby/Gems/1.8/gems/activesupport-3.2.10/lib/active_support/dependencies.rb:236:in `load_dependency'
/Library/Ruby/Gems/1.8/gems/activesupport-3.2.10/lib/active_support/dependencies.rb:251:in `require'
/Library/Ruby/Gems/1.8/gems/railties-3.2.10/lib/rails/generators.rb:300:in `lookup'
/Library/Ruby/Gems/1.8/gems/railties-3.2.10/lib/rails/generators.rb:296:in `each'
/Library/Ruby/Gems/1.8/gems/railties-3.2.10/lib/rails/generators.rb:296:in `lookup'
/Library/Ruby/Gems/1.8/gems/railties-3.2.10/lib/rails/generators.rb:295:in `each'
/Library/Ruby/Gems/1.8/gems/railties-3.2.10/lib/rails/generators.rb:295:in `lookup'
/Library/Ruby/Gems/1.8/gems/railties-3.2.10/lib/rails/generators.rb:152:in `find_by_namespace'
/Library/Ruby/Gems/1.8/gems/railties-3.2.10/lib/rails/generators.rb:169:in `invoke'
/Library/Ruby/Gems/1.8/gems/railties-3.2.10/lib/rails/commands/generate.rb:12
/Library/Ruby/Gems/1.8/gems/activesupport-3.2.10/lib/active_support/dependencies.rb:251:in `require'
/Library/Ruby/Gems/1.8/gems/activesupport-3.2.10/lib/active_support/dependencies.rb:251:in `require'
/Library/Ruby/Gems/1.8/gems/activesupport-3.2.10/lib/active_support/dependencies.rb:236:in `load_dependency'
/Library/Ruby/Gems/1.8/gems/activesupport-3.2.10/lib/active_support/dependencies.rb:251:in `require'
/Library/Ruby/Gems/1.8/gems/railties-3.2.10/lib/rails/commands.rb:29
script/rails:6:in `require'
script/rails:6
Could not find generator shopify_app.

@Gissues:{"order":14.285714285714276,"status":"backlog"}

Cannot create app

I have:

  • Ruby 1.9.3p125 (2012-02-16 revision 34643) [x86_64-darwin10.8.0]
  • Rails 3.2.3

I went through those steps:

$ rails new "My App"
$ cd "My App"
$ echo "gem 'shopify_app'" >> Gemfile
$ bundle install
$ rails generate shopify_app <api-key> <api-secret>

As the app was generated I was asked to confirm the overwrite of all those files:

  • app/assets/javascripts/application.js
  • app/assets/stylesheets/application.css
  • app/views/layouts/application.html.erb
  • public/404.html
  • public/422.html
  • public/500.html

Then I went...

  $ rails server

I got this error:

Could not find gem 'less-rails-bootstrap (>= 0) ruby' in the gems available on this machine.
Run bundle install to install missing gems.

So I did, again:

  $ bundle install
  $ rails server

Then I got this error:

Exiting
/Users/carolinehill/.rvm/gems/ruby-1.9.3-p125/gems/railties-3.2.3/lib/rails/railtie/configuration.rb:85:in method_missing': undefined methodless' for #Rails::Application::Configuration:0x00000100ee6550 (NoMethodError)

undefined method `sub' for nil:NilClass

Hi there!

I got a problem trying shopify_app, I've followed the Installation and Usage section of this gem, nothing more. When I try to login with my shop I got this error message :

NoMethodError in SessionsController#create
undefined method `sub' for nil:NilClass
app/controllers/sessions_controller.rb:47:in `sanitize_shop_param'
app/controllers/sessions_controller.rb:32:in `authenticate'
app/controllers/sessions_controller.rb:7:in `create'

Any ideas?
Thanks

Test Suite isn't passing

While trying to work on the feature I was doing I came across one of the tests failing.

It's probably worth it to add Travis CI integration into this project so these things won't happen again in the future.

Logging the issue just so it's on our radar, I might get a chance to fix it. It's also a great newbie contributor bug to fix since it's mostly just investigation and figuring out what Mocha is doing weirdly.

  1) Error:
ConfigurationTest#test_defaults_to_empty_string:
TypeError: compared with non class/module
    /Users/csaunders/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/mocha-1.1.0/lib/mocha/class_method.rb:83:in `define_method'
    /Users/csaunders/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/mocha-1.1.0/lib/mocha/class_method.rb:83:in `restore_original_method'
    /Users/csaunders/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/mocha-1.1.0/lib/mocha/class_method.rb:24:in `unstub'
    /Users/csaunders/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/mocha-1.1.0/lib/mocha/central.rb:20:in `unstub'
    /Users/csaunders/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/mocha-1.1.0/lib/mocha/central.rb:27:in `unstub_all'
    /Users/csaunders/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/mocha-1.1.0/lib/mocha/mockery.rb:75:in `teardown'
    /Users/csaunders/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/mocha-1.1.0/lib/mocha/mockery.rb:26:in `teardown'
    /Users/csaunders/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/mocha-1.1.0/lib/mocha/hooks.rb:39:in `mocha_teardown'
    /Users/csaunders/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/mocha-1.1.0/lib/mocha/integration/mini_test/adapter.rb:48:in `after_teardown'

NoMethodError in rails 3.2.13

The fix for #70 implemented in #71 breaks shopify_app in rails 3.2.13 with a NoMethodError. Changing it back to before_configuration solves the issue. redacted trace from our app:

/.rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/railties-3.2.13/lib/rails/railtie/configuration.rb:85:in `method_missing': undefined method `shopify' for #<Rails::Application::Configuration:0x007fb8dc368ef8> (NoMethodError)
from /app/config/application.rb:16:in `<class:Application>'
from /app/config/application.rb:13:in `<module:App>'
from /app/config/application.rb:12:in `<top (required)>'
from /.rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/railties-3.2.13/lib/rails/commands.rb:53:in `require'
from /.rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/railties-3.2.13/lib/rails/commands.rb:53:in `block in <top (required)>'
from /.rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/railties-3.2.13/lib/rails/commands.rb:50:in `tap'
from /.rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/railties-3.2.13/lib/rails/commands.rb:50:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'

omniauth.rb file not copied during new app generation

During new app creation

rails generate shopify_app

does not copy config/initializers/omniauth.rb to new app.

To replicate:

  1. rails new test-app
  2. echo "gem 'shopify_app'" >> Gemfile
  3. bundle install
  4. rails generate shopify_app

Expected results:

config/initializers/omniauth.rb file is copied to new app.

Current output:

$ rails generate shopify_app
exist app
create app/controllers/home_controller.rb
create app/controllers/login_controller.rb
create app/helpers/home_helper.rb
create app/helpers/login_helper.rb
create app/helpers/tabs_helper.rb
create app/views/home/design.html.erb
create app/views/home/index.html.erb
create app/views/home/welcome.html.erb
conflict app/views/layouts/application.html.erb
Overwrite /Users/jnormore/work/test-app2/app/views/layouts/application.html.erb? (enter "h" for help) [Ynaqdh] y
force app/views/layouts/application.html.erb
create app/views/login/index.html.erb
exist public
create public/images/box-bg2.gif
create public/images/info-bg.gif
create public/images/info.gif
create public/images/shopify-logo.png
create public/stylesheets/application.css
remove public/index.html
insert config/application.rb
route match 'login/logout' => 'login#logout'
route match 'login/finalize' => 'login#finalize'
route match 'login/authenticate' => 'login#authenticate'
route match 'login' => 'login#index'
route match 'design' => 'home#design'
route match 'welcome' => 'home#welcome'
route root :to => 'home#index'

Error in `generate shopify_app` - Rails 3.2.10, Ruby 1.8.7

meekohi ~/aball.web/shopify-arqspin$ rails generate shopify_app APIKEY SECRET
Faraday: you may want to install system_timer for reliable timeouts
/Library/Ruby/Gems/1.8/gems/shopify_app-4.1.0/lib/shopify_app.rb:15:in require': /Library/Ruby/Gems/1.8/gems/shopify_app-4.1.0/lib/shopify_app/login_protection.rb:5: syntax error, unexpected ':', expecting kEND (SyntaxError) ...rce::UnauthorizedAccess, with: :close_session ^ from /Library/Ruby/Gems/1.8/gems/shopify_app-4.1.0/lib/shopify_app.rb:15 from /Library/Ruby/Gems/1.8/gems/bundler-1.1.0/lib/bundler/runtime.rb:68:inrequire'
from /Library/Ruby/Gems/1.8/gems/bundler-1.1.0/lib/bundler/runtime.rb:68:in require' from /Library/Ruby/Gems/1.8/gems/bundler-1.1.0/lib/bundler/runtime.rb:66:ineach'
from /Library/Ruby/Gems/1.8/gems/bundler-1.1.0/lib/bundler/runtime.rb:66:in require' from /Library/Ruby/Gems/1.8/gems/bundler-1.1.0/lib/bundler/runtime.rb:55:ineach'
from /Library/Ruby/Gems/1.8/gems/bundler-1.1.0/lib/bundler/runtime.rb:55:in require' from /Library/Ruby/Gems/1.8/gems/bundler-1.1.0/lib/bundler.rb:118:inrequire'
from /Users/meekohi/shopify-arqspin/config/application.rb:7
from /Library/Ruby/Gems/1.8/gems/railties-3.2.10/lib/rails/commands.rb:24:in require' from /Library/Ruby/Gems/1.8/gems/railties-3.2.10/lib/rails/commands.rb:24 from script/rails:6:inrequire'
from script/rails:6

LoginController#authenticate - undefined method 'create_permission_url'

EDIT : I moved this issue to shopify_api, here -> Shopify/shopify-api-ruby#29
Hi Everyone,

Everytime I want to login with one of my Test Shops I get this error:

error

The only thing I have in that line is

code

Sometimes I get this error in my application, and normally it works after a couple of tries, but this time I can't get my application to work. This is just after I insert the shop url.

I never knew why this is happening, and now I don't know how to fix this, because it always worked, and this seems to be the same code has this one in here:

http://rdoc.info:8080/github/Shopify/shopify_api/master/ShopifyAPI/Session#create_permission_url-instance_method

I also tried to do

s = ShopifyAPI::Session.new(params[:shop])
s..valid? # return was false

Thank you for your time

therubyracer dependency issues in Windows

Encountering issues in Windows 7, Ruby 1.9.3, Rails 3.2.8.
Running rails server after generating the Shopify app gives the following error:
[WARNING] Please install gem 'therubyracer' to use Less.
The gem therubyracer is not compatible with Windows. The dependency is coming from twitter-bootstrap/LESS. Adding the following line to the Gemfile:
gem 'twitter-bootstrap-rails', :git => "git://github.com/seyhunak/twitter-bootstrap-rails.git", :branch => "static"
should theoretically solve the issue, though the rails server will not run, the error is as follows:
git://github.com/seyhunak/twitter-bootstrap-rails.git (at static) is not checked out. Please run 'bundle install'
Running bundle install at this point is returning a fatal error.
@Gissues:{"order":57.14285714285713,"status":"backlog"}

Openssl issues with the gem on Ubuntu 12.04

Hi,

I am able to use this gem without any issue on my development machine where I am using Pow, Nginx and a self-signed SSL certificate, but on production, once the user does the OAuth login from Shopify, the /auth/shopify/callback?params.. request results in a 502 error.

I am only facing this issue after adding SSL to the app.

This issue has been discussed earlier on Stackoverflow and Shopify App Discuss Google Group, but no conclusive solution was reached. The relevant discussions are:
SSL connection reset error,
SSL_connect error when accessing Shopify API with rubygem,
Shopify + Ubuntu 12.04LTS + Faraday issue = OK to use older OpenSSL?,
Omniauth Farraday Error and
Shopify - creating session for private app

In all the discussions, two things have been highlighted - Openssl 1.0.1 on Ubuntu 12.04 is buggy and Shopify has some issues with SSLv2 which are fixed by using TLSv1 I tried using TLSv1 but that did not solve my error. Downgrading openssl gives me an error when I try to install other packages like git.

The relevant logs from my application:

OpenSSL 1.0.1 14 Mar 2012

nginx version: nginx/1.4.1

unicorn.log

(shopify) Setup endpoint detected, running now.
(shopify) Callback phase initiated.
E, [2013-08-30T16:30:07.151259 #16692] ERROR -- : worker=1 PID:17296 timeout (61s > 60s), killing
E, [2013-08-30T16:30:07.158877 #16692] ERROR -- : reaped #<Process::Status: pid 17296 SIGKILL (signal 9)> worker=1
I, [2013-08-30T16:30:07.159060 #16692]  INFO -- : worker=1 spawning...
I, [2013-08-30T16:30:07.161428 #25200]  INFO -- : worker=1 spawned pid=25200
I, [2013-08-30T16:30:07.161854 #25200]  INFO -- : Refreshing Gem list
I, [2013-08-30T16:30:09.970701 #25200]  INFO -- : worker=1 ready

production.log

Started GET "/login" for 127.0.0.1 at 2013-08-30 16:28:56 +0530
Processing by SessionsController#new as HTML
  Rendered sessions/new.html.erb within layouts/application (2.9ms)
  Rendered shared/_flash_messages.html.erb (0.1ms)
Completed 200 OK in 8ms (Views: 7.3ms | ActiveRecord: 0.0ms)
Started POST "/login" for 127.0.0.1 at 2013-08-30 16:29:04 +0530
Processing by SessionsController#create as HTML
  Parameters: {"utf8"=>"รข", "authenticity_token"=>"..............", "shop"=>"aramex-app.myshopify.com", "commit"=>"Login"}
Redirected to https://shopify.aramex.com/auth/shopify?shop=aramex-app.myshopify.com
Completed 302 Found in 1ms (ActiveRecord: 0.0ms)
Started GET "/auth/shopify?shop=aramex-app.myshopify.com" for 127.0.0.1 at 2013-08-30 16:29:04 +0530
Started GET "/auth/shopify/callback?code=..................&shop=aramex-app.myshopify.com&timestamp=1377860358&signature=................" for 127.0.0.1 at 2013-08-30 16:29:06 +0530
Connecting to database specified by database.yml

Nginx Access.log

10.27.1.3 - - [30/Aug/2013:16:28:56 +0530] "GET /login HTTP/1.1" 304 0 "https://shopify.aramex.com/login" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1547.57 Safari/537.36"
10.27.1.3 - - [30/Aug/2013:16:29:04 +0530] "POST /login HTTP/1.1" 302 146 "https://shopify.aramex.com/auth/shopify?shop=aramex-app.shopify.com" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1547.57 Safari/537.36"
10.27.1.3 - - [30/Aug/2013:16:29:04 +0530] "GET /auth/shopify?shop=aramex-app.myshopify.com HTTP/1.1" 302 299 "https://shopify.aramex.com/auth/shopify?shop=aramex-app.shopify.com" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1547.57 Safari/537.36"
10.27.1.3 - - [30/Aug/2013:16:30:06 +0530] "GET /auth/shopify/callback?code=0067d4f85c170a2e0d6d1a2ac0524c93&shop=aramex-app.myshopify.com&timestamp=1377860358&signature=dfa8eabd78570c9b8fb0cea6166656c4 HTTP/1.1" 504 1060 "https://aramex-app.myshopify.com/admin/oauth/authorize?response_type=code&client_id=61e9a7dc41c5bf513c6e769dc6b76f4e&redirect_uri=https%3A%2F%2Fshopify.aramex.com%2Fauth%2Fshopify%2Fcallback&state=99c929ace84a618be0a7b619c77b80e1f2141e49f0f6932b&scope=write_orders%2C+read_products" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1547.57 Safari/537.36"
10.27.1.3 - - [30/Aug/2013:16:30:07 +0530] "GET /favicon.ico HTTP/1.1" 304 0 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1547.57 Safari/537.36"

Nginx error.log

2013/08/30 16:30:06 [error] 15844#0: *305 upstream timed out (110: Connection timed out) while reading response header from upstream, client: 10.27.1.3, server: shopify.aramex.com, request: "GET /auth/shopify/callback?code=0067d4f85c170a2e0d6d1a2ac0524c93&shop=aramex-app.myshopify.com&timestamp=1377860358&signature=dfa8eabd78570c9b8fb0cea6166656c4 HTTP/1.1", upstream: "http://unix:/tmp/unicorn.shopify_aramex.sock/auth/shopify/callback?code=0067d4f85c170a2e0d6d1a2ac0524c93&shop=aramex-app.myshopify.com&timestamp=1377860358&signature=dfa8eabd78570c9b8fb0cea6166656c4", host: "shopify.aramex.com", referrer: "https://aramex-app.myshopify.com/admin/oauth/authorize?response_type=code&client_id=61e9a7dc41c5bf513c6e769dc6b76f4e&redirect_uri=https%3A%2F%2Fshopify.aramex.com%2Fauth%2Fshopify%2Fcallback&state=99c929ace84a618be0a7b619c77b80e1f2141e49f0f6932b&scope=write_orders%2C+read_products"

Since many others have faced this issue, I would like to know whether the problem is exclusively due to Openssl, (in which case, we should add a suggestion to the README to avoid Ubuntu 12.04) or has anything to do with this gem.

Version 5.0.0 breaks less, bootstrap and icons...

I was successfully using the following Gems...
less (2.5.1)
less-rails (2.5.0)
less-rails-bootstrap (3.2.0)

When I updated to the shopify_app 5.0.0 it forced them to downgrade to lower versions...
less 2.3.3
less-rails 2.3.3
less-rails-bootstrap 2.3.3

This has broken major theme elements and icons. How can I fix this?


This commit
10335d5

Locked Bootstrap to 2.0...
Why on earth would you do this?? I cannot see any legitimate reason to lock down the css framework.

Error when using with Rails 4.1.0.beta1

I get the following error when trying to run the generator:

~/code/myapp (master) $ rails generate shopify_app my_api_key my_api_secret
/Users/manuel/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/shopify_app-4.2.3/lib/shopify_app/configuration.rb:43:in `join': no implicit conversion of nil into String (TypeError)
  from /Users/manuel/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/shopify_app-4.2.3/lib/shopify_app/configuration.rb:43:in `default_params'
  from /Users/manuel/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/shopify_app-4.2.3/lib/shopify_app/configuration.rb:6:in `initialize'
  from /Users/manuel/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/shopify_app-4.2.3/lib/shopify_app.rb:7:in `new'
  from /Users/manuel/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/shopify_app-4.2.3/lib/shopify_app.rb:7:in `configuration'
  from /Users/manuel/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/shopify_app-4.2.3/lib/shopify_app/railtie.rb:6:in `block in <class:Railtie>'
  from /Users/manuel/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/activesupport-4.1.0.beta1/lib/active_support/lazy_load_hooks.rb:36:in `call'
  from /Users/manuel/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/activesupport-4.1.0.beta1/lib/active_support/lazy_load_hooks.rb:36:in `execute_hook'
  from /Users/manuel/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/activesupport-4.1.0.beta1/lib/active_support/lazy_load_hooks.rb:45:in `block in run_load_hooks'
  from /Users/manuel/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/activesupport-4.1.0.beta1/lib/active_support/lazy_load_hooks.rb:44:in `each'
  from /Users/manuel/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/activesupport-4.1.0.beta1/lib/active_support/lazy_load_hooks.rb:44:in `run_load_hooks'
  from /Users/manuel/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/railties-4.1.0.beta1/lib/rails/application.rb:121:in `initialize'
  from /Users/manuel/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/railties-4.1.0.beta1/lib/rails/railtie.rb:171:in `new'
  from /Users/manuel/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/railties-4.1.0.beta1/lib/rails/railtie.rb:171:in `instance'
  from /Users/manuel/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/railties-4.1.0.beta1/lib/rails/application.rb:90:in `inherited'
  from /Users/manuel/code/myapp/config/application.rb:17:in `<module:MyApp>'
  from /Users/manuel/code/myapp/config/application.rb:16:in `<top (required)>'
  from /Users/manuel/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/railties-4.1.0.beta1/lib/rails/commands/commands_tasks.rb:146:in `require'
  from /Users/manuel/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/railties-4.1.0.beta1/lib/rails/commands/commands_tasks.rb:146:in `require_application_and_environment!'
  from /Users/manuel/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/railties-4.1.0.beta1/lib/rails/commands/commands_tasks.rb:133:in `generate_or_destroy'
  from /Users/manuel/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/railties-4.1.0.beta1/lib/rails/commands/commands_tasks.rb:51:in `generate'
  from /Users/manuel/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/railties-4.1.0.beta1/lib/rails/commands/commands_tasks.rb:40:in `run_command!'
  from /Users/manuel/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/railties-4.1.0.beta1/lib/rails/commands.rb:17:in `<top (required)>'
  from bin/rails:4:in `require'
  from bin/rails:4:in `<main>'

I guess Rails.root is nil in config.before_configuration? Maybe change it to config.before_initialize?

How to integration test the redirects to permission_url?

I have this embedded app that requires the user to modify the product, and I'm trying to write a test for that flow, but the problem is that it needs to redirect me to

 https://my-pretty-shop.myshopify.com/admin/oauth/authorize

With the authentication flow, this was easy: OmniAuth's test mode simply moves me forward to the callback step, but I'm not sure with this one. I have no control over the redirection. I need some advice please.

Faraday::Error::ConnectionFailed error when accessing app.

Hey guys,

I just generated an app using shopify_app. I have done this before. I know how to do that.

I am using Ruby 1.9.3p194 with Rails 3.2.12, on MacOS Mountain Lion.

When I install the app in a store, I get this error:

Faraday::Error::ConnectionFailed
SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed

The app seems installed, I just can't access it.

Sample of Full Trace leading to error:

  /usr/local/rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/net/http.rb:799:in `connect'
  /usr/local/rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/net/http.rb:799:in `block in connect'
  /usr/local/rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/timeout.rb:54:in `timeout'
  /usr/local/rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/timeout.rb:99:in `timeout'
  /usr/local/rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/net/http.rb:799:in `connect'
  /usr/local/rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/net/http.rb:755:in `do_start'
  /usr/local/rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/net/http.rb:744:in `start'
  /usr/local/rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/net/http.rb:1284:in `request'
  faraday (0.8.6) lib/faraday/adapter/net_http.rb:75:in `perform_request'
  faraday (0.8.6) lib/faraday/adapter/net_http.rb:38:in `call'
  faraday (0.8.6) lib/faraday/request/url_encoded.rb:14:in `call'
  faraday (0.8.6) lib/faraday/connection.rb:247:in `run_request'
  oauth2 (0.8.1) lib/oauth2/client.rb:88:in `request'
  oauth2 (0.8.1) lib/oauth2/client.rb:131:in `get_token'
  oauth2 (0.8.1) lib/oauth2/strategy/auth_code.rb:29:in `get_token'
  omniauth-oauth2 (1.0.3) lib/omniauth/strategies/oauth2.rb:87:in `build_access_token'
  omniauth-oauth2 (1.0.3) lib/omniauth/strategies/oauth2.rb:62:in `callback_phase'
  omniauth (1.1.3) lib/omniauth/strategy.rb:219:in `callback_call'
  omniauth (1.1.3) lib/omniauth/strategy.rb:175:in `call!'
  omniauth (1.1.3) lib/omniauth/strategy.rb:157:in `call'
  omniauth (1.1.3) lib/omniauth/builder.rb:48:in `call'

couldn't find file 'twitter/bootstrap'

I just got the exception with a fresh, plain rails 4.0.1 app:

couldn't find file 'twitter/bootstrap'

After reading this: metaskills/less-rails-bootstrap#93, I added require 'less-rails-bootstrap' to application.rb and enabled gem 'therubyracer', platforms: :ruby for production - tataaa the exception is gone.

Pls verify and I'll create a PR

default install of shopify_app does not deploy cleanly to Heroku cedar stack

The shopify_app code does not cleanly deploy to Heroku Cedar Stack with rails 3.2. A number of errors appear:

Steps to reproduce:

  1. create a new rails app
  2. deploy to heroku cedar (notice that the app works)
  3. install the shopify_app
  4. deploy to heroku cedar stack and notice the following errors

When running heroku run rake db:migrate...
DEPRECATION WARNING: You have Rails 2.3-style plugins in vendor/plugins! Support for these plugins will be removed in Rails 4.0. Move them out and bundle them in your Gemfile, or fold them in to your app as lib/myplugin/* and config/initializers/myplugin.rb. See the release notes for more on this: http://weblog.rubyonrails.org/2012/1/4/rails-3-2-0-rc2-has-been-released. (called from <top (required)> at /app/Rakefile:7)
DEPRECATION WARNING: You have Rails 2.3-style plugins in vendor/plugins! Support for these plugins will be removed in Rails 4.0. Move them out and bundle them in your Gemfile, or fold them in to your app as lib/myplugin/* and config/initializers/myplugin.rb. See the release notes for more on this: http://weblog.rubyonrails.org/2012/1/4/rails-3-2-0-rc2-has-been-released. (called from <top (required)> at /app/Rakefile:7)

when accessing http://some-app-1186.herokuapp.com...
AH! 500 Error!
2012-06-19T23:40:33+00:00 app[web.1]: ActionController::RoutingError (No route matches [GET] "/assets/shopify_app.scss"):
2012-06-19T23:40:33+00:00 app[web.1]: ActionController::RoutingError (No route matches [GET] "/assets/bootstrap.css"):
2012-06-19T23:40:33+00:00 heroku[router]: GET some-app-1186.herokuapp.com/assets/bootstrap.css dyno=web.1 queue=0 wait=0ms service=20ms status=404 bytes=1458
2012-06-19T23:40:34+00:00 heroku[router]: GET some-app-1186.herokuapp.com/favicon.ico dyno=web.1 queue=0 wait=0ms service=59ms status=200 bytes=0

No documentation

http://api.shopify.com/index.html doesn't have a Ruby/Rails section. For example, how would I figure out that ShopifyAPI::ScriptTag.create maps to POST /admin/script_tags.json? In particular, how do I add a Product Image to a Product?
@Gissues:{"order":85.71428571428571,"status":"backlog"}

NoMethodError in LoginController#authenticate

I tried a vanilla install of the shopify_app.

On this page:
http://localhost:3000/login

When you provide the subdomain or the URL and click Install, I get:

NoMethodError in LoginController#authenticate

undefined method `create_permission_url' for #ShopifyAPI::Session:0x00000104397c90
Rails.root: /Users/leonardteo/Documents/railsprojects/shopify_test

Application Trace | Framework Trace | Full Trace
app/controllers/login_controller.rb:13:in `authenticate'

Rails 4.1 and default cookie store session store broken

I posted a detailed writeup of this issue here:
http://stackoverflow.com/questions/22978704/object-stored-in-rails-session-becomes-a-string

The greater issue is that it is widely agreed that storing objects in the Rails session is a BAD idea. Yehuda Katz gives makes the case here: http://stackoverflow.com/a/1096221/1284634

Looking through the code base it would be very easy to modify the codebase to pass just the shop and token and create the session internally in the gem lib:

https://github.com/Shopify/shopify_app/blob/master/lib/generators/shopify_app/templates/app/controllers/sessions_controller.rb#L12-L13

I'm willing to put in a pull request if this is a desired change...

generator not found using Rails 3.1.2

At the Shopify Hackfest last Saturday, a participant reported not being able to use the Shopify app generator with a fresh app created using Rails 3.1.2

Issue with ruby 1.9.1

When installing the plugin I get

/vendor/plugins/shopify_app/install.rb:8: invalid multibyte char (US-ASCII)

It's the fancy quotes that's doing it.

A copy of Shop has been removed from the module tree but is still active!

While using shopify_app in development I keep getting this error:

ArgumentError - A copy of Shop has been removed from the module tree but is still active!:
activesupport (4.1.4) lib/active_support/dependencies.rb:465:in `load_missing_constant'
activesupport (4.1.4) lib/active_support/dependencies.rb:180:in `const_missing'
app/models/shop.rb:9:in `retrieve'
shopify_app (5.0.0) lib/shopify_app/shopify_session_repository.rb:10:in `retrieve'
app/controllers/surveys_controller.rb:4:in `index'
actionpack (4.1.4) lib/action_controller/metal/implicit_render.rb:4:in `send_action'
actionpack (4.1.4) lib/abstract_controller/base.rb:189:in `process_action'
actionpack (4.1.4) lib/action_controller/metal/rendering.rb:10:in `process_action'
actionpack (4.1.4) lib/abstract_controller/callbacks.rb:20:in `block in process_action'
activesupport (4.1.4) lib/active_support/callbacks.rb:113:in `call'
activesupport (4.1.4) lib/active_support/callbacks.rb:229:in `block in halting'
activesupport (4.1.4) lib/active_support/callbacks.rb:166:in `block in halting'
activesupport (4.1.4) lib/active_support/callbacks.rb:86:in `run_callbacks'
actionpack (4.1.4) lib/abstract_controller/callbacks.rb:19:in `process_action'
actionpack (4.1.4) lib/action_controller/metal/rescue.rb:29:in `process_action'
actionpack (4.1.4) lib/action_controller/metal/instrumentation.rb:31:in `block in process_action'
activesupport (4.1.4) lib/active_support/notifications.rb:159:in `block in instrument'
activesupport (4.1.4) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
activesupport (4.1.4) lib/active_support/notifications.rb:159:in `instrument'
actionpack (4.1.4) lib/action_controller/metal/instrumentation.rb:30:in `process_action'
actionpack (4.1.4) lib/action_controller/metal/params_wrapper.rb:250:in `process_action'
activerecord (4.1.4) lib/active_record/railties/controller_runtime.rb:18:in `process_action'
actionpack (4.1.4) lib/abstract_controller/base.rb:136:in `process'
actionview (4.1.4) lib/action_view/rendering.rb:30:in `process'
actionpack (4.1.4) lib/action_controller/metal.rb:196:in `dispatch'
actionpack (4.1.4) lib/action_controller/metal/rack_delegation.rb:13:in `dispatch'
actionpack (4.1.4) lib/action_controller/metal.rb:232:in `block in action'
actionpack (4.1.4) lib/action_dispatch/routing/route_set.rb:82:in `dispatch'
actionpack (4.1.4) lib/action_dispatch/routing/route_set.rb:50:in `call'
actionpack (4.1.4) lib/action_dispatch/journey/router.rb:71:in `block in call'
actionpack (4.1.4) lib/action_dispatch/journey/router.rb:59:in `call'
actionpack (4.1.4) lib/action_dispatch/routing/route_set.rb:678:in `call'
newrelic_rpm (3.8.1.221) lib/new_relic/rack/error_collector.rb:55:in `call'
newrelic_rpm (3.8.1.221) lib/new_relic/rack/agent_hooks.rb:32:in `call'
newrelic_rpm (3.8.1.221) lib/new_relic/rack/browser_monitoring.rb:27:in `call'
newrelic_rpm (3.8.1.221) lib/new_relic/rack/developer_mode.rb:45:in `call'
omniauth (1.2.2) lib/omniauth/strategy.rb:186:in `call!'
omniauth (1.2.2) lib/omniauth/strategy.rb:164:in `call'
omniauth (1.2.2) lib/omniauth/builder.rb:59: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.1.4) lib/action_dispatch/middleware/params_parser.rb:27:in `call'
actionpack (4.1.4) lib/action_dispatch/middleware/flash.rb:254: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.1.4) lib/action_dispatch/middleware/cookies.rb:560:in `call'
activerecord (4.1.4) lib/active_record/query_cache.rb:36:in `call'
activerecord (4.1.4) lib/active_record/connection_adapters/abstract/connection_pool.rb:621:in `call'
activerecord (4.1.4) lib/active_record/migration.rb:380:in `call'
actionpack (4.1.4) lib/action_dispatch/middleware/callbacks.rb:29:in `block in call'
activesupport (4.1.4) lib/active_support/callbacks.rb:82:in `run_callbacks'
actionpack (4.1.4) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
actionpack (4.1.4) lib/action_dispatch/middleware/reloader.rb:73:in `call'
actionpack (4.1.4) lib/action_dispatch/middleware/remote_ip.rb:76:in `call'
better_errors (1.1.0) lib/better_errors/middleware.rb:84:in `protected_app_call'
better_errors (1.1.0) lib/better_errors/middleware.rb:79:in `better_errors_call'
better_errors (1.1.0) lib/better_errors/middleware.rb:56:in `call'
actionpack (4.1.4) lib/action_dispatch/middleware/debug_exceptions.rb:17:in `call'
actionpack (4.1.4) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
railties (4.1.4) lib/rails/rack/logger.rb:38:in `call_app'
railties (4.1.4) lib/rails/rack/logger.rb:20:in `block in call'
activesupport (4.1.4) lib/active_support/tagged_logging.rb:68:in `block in tagged'
activesupport (4.1.4) lib/active_support/tagged_logging.rb:26:in `tagged'
activesupport (4.1.4) lib/active_support/tagged_logging.rb:68:in `tagged'
railties (4.1.4) lib/rails/rack/logger.rb:20:in `call'
actionpack (4.1.4) 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.1.4) lib/active_support/cache/strategy/local_cache_middleware.rb:26:in `call'
rack (1.5.2) lib/rack/lock.rb:17:in `call'
actionpack (4.1.4) lib/action_dispatch/middleware/static.rb:64:in `call'
rack (1.5.2) lib/rack/sendfile.rb:112:in `call'
railties (4.1.4) lib/rails/engine.rb:514:in `call'
railties (4.1.4) lib/rails/application.rb:144: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'
/Users/joelbrewer/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/webrick/httpserver.rb:138:in `service'
/Users/joelbrewer/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/webrick/httpserver.rb:94:in `run'
/Users/joelbrewer/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/webrick/server.rb:295:in `block in    start_thread'

The only way to get this error to go away is to restart my development server ( a real PITA ).

My shopify_session_repository.rb file looks like this:

ShopifySessionRepository.storage = Shop

and my shop.rb file looks like this:

class Shop < ActiveRecord::Base
  def self.store(session)
    shop = Shop.new(domain: session.url, token: session.token)
    shop.save!
    shop.id
  end
  def self.retrieve(id)
    if shop = Shop.where(id: id).first
      ShopifyAPI::Session.new(shop.domain, shop.token)
    end
  end
end

What's going on here? I've done a bit of digging around and I think it has something to do with the way Rails autoloads certain files, but I don't know enough about the core code to fix the issue.

Rails 3 generator compatibility

Hi guys,

I get the following warning when trying to run rake rails:upgrade:check while preparing our app for R3.

Old Rails generator API 
A plugin in the app is using the old generator API (a new one may be available at      http://github.com/trydionel/rails3-generators).
More information: http://blog.plataformatec.com.br/2010/01/discovering-rails-3-generators/
The culprits: 
   ....
- vendor/plugins/shopify_app/generators/
- vendor/plugins/shopify_app/generators/shopify_app/

Thanks guys!

question to the "OmniAuth::Builder" and shop parameter

Hey,

i'm curious which purpose the params['shop']parameter has. I get that you have to redirect the client to the proper myshopify.com after autentication...

the code i`m talking about: L11

:setup => lambda {|env| 
                       params = Rack::Utils.parse_query(env['QUERY_STRING'])
                       site_url = "https://#{params['shop']}"
                       env['omniauth.strategy'].options[:client_options][:site] = site_url
                     }

....but why do you extract the param from env['QUERY_STRING']? i could just change the code to:

:setup => lambda {|env| 
                       env['omniauth.strategy'].options[:client_options][:site] = config.shopify.shop_url
                     }

given that i have shop_urlin my config.shopify configs. right?

build gem

@edward, @davefp

Can either of you bump the version number and build a new gem for this? I merge the stylesheet fix and fixed a few broken routes.

Getting an error following the readme

Hi there

I apologise if this is me being an idiot. I'm still very new to rails. I tried to follow the readme file and have run in to an issue. When I try and add a shop I get the following error:

NoMethodError in SessionsController#create

Can anyone help?

Incorrect application callback URL in README

In this project's README, you say:

When you create your app in the Shopify Partner Account, set the Application Callback URL to

http://localhost:3000

But then in the README inside lib/generators/shopify_app it says:

Make sure to set the Application URL of the application in your Shopify partner account
to http://localhost:3000/login

Setting the callback to the site root doesn't work, but setting it to /login does, so I presume the main README is incorrect here?

:order => "created_at DESC" is not a valid parameter for the Order query

In: home_controller.rb Line: 15
https://github.com/Shopify/shopify_app/blob/master/lib/generators/shopify_app/templates/app/controllers/home_controller.rb#L15

The :order => "created_at DESC" parameter is not valid. In other words, it does not work.

This is because the Shopify API is an ActiveResource, the parameter order does not work in the same way that it would with an ActiveRecord model.

limit is one of the end points of Order, so that parameter works.
http://docs.shopify.com/api/order#index

License?

Hi,

What license is this shopify_app released under?

Login Protection causing issues

So I use the following to start a session and it was working until a few days ago now it just triggers the login protection to send the browser back to /login

Funny thing is on my development server using the same exact code it works as expected even when running in production. However I put it on my production server and run in production mode and it just redirects me to /login via the login_protection script.

        session = ShopifyAPI::Session.new(@shop.shopUrl, @shop.shopToken)
        ShopifyAPI::Base.activate_session(session)
                order = ShopifyAPI::Order.find(2432114111)

Any idea as to what is going on here?

ActiveResource 4.0.0
Activesupport 4.0.0
Rails 4.0.0
shopify_api 3.0.3
shopify_app 4.2.3

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.