FAQ
Hi all,

Can anyone please tell me how I create an extension that requires it's own
db table? Based on the extension tutorial at
http://guides.spreecommerce.com/developer/extensions_tutorial.html it looks
like I should create the migration in the spree store and it will be run
when I run the install generator. However, I don't see my new 'offers'
table in the db and my site page gives the following error:

NameError in Spree::HomeController#offers

uninitialized constant Spree::Offer



Also - I need to add a row to this table but do I run rails console from
the store directory, or from the extension directory? The tutorial is
unclear.

Thanks.

Search Discussions

  • Gregor MacDougall at Jun 24, 2013 at 1:48 pm
    The basic steps are:


        1. Create the migration in your extension
        2. Install an updated version of your extension in your application
        3. run rake railties:install:migratiions from your application to copy
        the migration from your extension to your application
        4. run rake db:migrate from your application

    That should create the table you require.

    Any time you want to add rows to your table you should do so from your
    application.

    --
    Gregor MacDougall
    Sr. Software Developer @ FreeRunning Technologies
    (http://www.freerunningtech.com/
    )
    On Sunday, June 23, 2013 3:34:31 PM UTC-7, obregon cornsnook wrote:

    Hi all,

    Can anyone please tell me how I create an extension that requires it's own
    db table? Based on the extension tutorial at
    http://guides.spreecommerce.com/developer/extensions_tutorial.html it
    looks like I should create the migration in the spree store and it will be
    run when I run the install generator. However, I don't see my new 'offers'
    table in the db and my site page gives the following error:

    NameError in Spree::HomeController#offers

    uninitialized constant Spree::Offer



    Also - I need to add a row to this table but do I run rails console from
    the store directory, or from the extension directory? The tutorial is
    unclear.

    Thanks.
  • Ryan Bigg at Jul 8, 2013 at 11:27 pm
    Obregon:

    Please show us the code that you're using. Without code, this issue is
    extremely difficult for us to debug. Even just a link to the repo on GitHub
    with a short list of steps to reproduce the issue would be great.

    Thanks!


    On Fri, Jul 5, 2013 at 8:47 PM, obregon cornsnook
    wrote:
    Thanks for your response. I've managed to get this part working and can
    now use the extension db table in the rails console.

    I need to use the rails console to add rows though, as per the tutorial, because there's not yet any views created to add data.

    Now I don't see how to add views. The tutorial makes much of Deface but I don't understand which 'hook' I'm supposed to overwrite as my extension
    should produce a view separate from the store. It's not a products page as such.

    The routes file is ok, I just see a blank page when visiting the required url.
    How do I create view such that they will follow the application layout but contain their own content?

    On Monday, June 24, 2013 2:48:40 PM UTC+1, Gregor MacDougall wrote:

    The basic steps are:


    1. Create the migration in your extension
    2. Install an updated version of your extension in your application
    3. run rake railties:install:migratiions from your application to
    copy the migration from your extension to your application
    4. run rake db:migrate from your application

    That should create the table you require.

    Any time you want to add rows to your table you should do so from your
    application.

    --
    Gregor MacDougall
    Sr. Software Developer @ FreeRunning Technologies (
    http://www.freerunningtech.**com/ <http://www.freerunningtech.com/>
    )
    On Sunday, June 23, 2013 3:34:31 PM UTC-7, obregon cornsnook wrote:

    Hi all,

    Can anyone please tell me how I create an extension that requires it's
    own db table? Based on the extension tutorial at
    http://guides.spreecommerce.**com/developer/extensions_**tutorial.html<http://guides.spreecommerce.com/developer/extensions_tutorial.html>it looks like I should create the migration in the spree store and it will
    be run when I run the install generator. However, I don't see my new
    'offers' table in the db and my site page gives the following error:

    NameError in Spree::HomeController#offers

    uninitialized constant Spree::Offer



    Also - I need to add a row to this table but do I run rails console from
    the store directory, or from the extension directory? The tutorial is
    unclear.

    Thanks.

    --

    Ryan Bigg
    Community Manager
    Spree Commerce, Inc.
  • Weston Platter at Jul 9, 2013 at 8:44 pm
    Hi Obergon,

    Yeah, working with spree extensions can be confusing at first. I was
    greatly helped by looking at other spree extensions
    (http://spreecommerce.com/extensions).

    Here's a couple suggestions I've copy and pasted a lot from.

        - https://github.com/spree/spree-product-assembly


        - https://github.com/spree/spree_social


        - https://github.com/spree/spree_related_products



    On Friday, July 5, 2013 4:47:13 AM UTC-6, obregon cornsnook wrote:

    Thanks for your response. I've managed to get this part working and can
    now use the extension db table in the rails console.

    I need to use the rails console to add rows though, as per the tutorial, because there's not yet any views created to add data.

    Now I don't see how to add views. The tutorial makes much of Deface but I don't understand which 'hook' I'm supposed to overwrite as my extension
    should produce a view separate from the store. It's not a products page as such.

    The routes file is ok, I just see a blank page when visiting the required url.
    How do I create view such that they will follow the application layout but contain their own content?

    On Monday, June 24, 2013 2:48:40 PM UTC+1, Gregor MacDougall wrote:

    The basic steps are:


    1. Create the migration in your extension
    2. Install an updated version of your extension in your application
    3. run rake railties:install:migratiions from your application to
    copy the migration from your extension to your application
    4. run rake db:migrate from your application

    That should create the table you require.

    Any time you want to add rows to your table you should do so from your
    application.

    --
    Gregor MacDougall
    Sr. Software Developer @ FreeRunning Technologies (
    http://www.freerunningtech.com/
    )
    On Sunday, June 23, 2013 3:34:31 PM UTC-7, obregon cornsnook wrote:

    Hi all,

    Can anyone please tell me how I create an extension that requires it's
    own db table? Based on the extension tutorial at
    http://guides.spreecommerce.com/developer/extensions_tutorial.html it
    looks like I should create the migration in the spree store and it will be
    run when I run the install generator. However, I don't see my new 'offers'
    table in the db and my site page gives the following error:

    NameError in Spree::HomeController#offers

    uninitialized constant Spree::Offer



    Also - I need to add a row to this table but do I run rails console from
    the store directory, or from the extension directory? The tutorial is
    unclear.

    Thanks.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupspree-user @
categoriesrubyonrails
postedJun 24, '13 at 8:51a
activeJul 9, '13 at 8:44p
posts4
users4
websitespreecommerce.com
irc#RubyOnRails

People

Translate

site design / logo © 2022 Grokbase