Darren Nickerson

Joined

510 Experience
4 Lessons Completed
0 Questions Solved

Activity

Posted in acts_as_shopping_cart documentation?

Hello everyone, I'm trying to build a shopping cart for my new project and i decided to use the acts_as_shopping_cart gem, well didnt really decide to but really the only one i could find without going the spree route. Does anyone know of any good tutorials or basic doumentation other than whats found on the github page? https://github.com/crowdint/acts_as_shopping_cart & https://github.com/crowdint/acts_as_shopping_cart_app Its unclear in the sample application on how to create a new product, when I create a new product on my app it says, 2 errors, owner needs to exist and item needs to exist. Can anyone help me out with this, or have a better solution for creating a cart. This gem is quite a few years old now.

Posted in User Profile with devise

Thanks Chris! This cleared up a few different things for me. I appreciate the thorough answer :)

Posted in User Profile with devise

Hello I'm new to rails and I am trying to work with the has_one association. I'm using Devise for authentication. I was each user to have a profile (which will include their address and some other information that I may need later on. I thought about creating a migration to add these to the user model but thought it would make it bloated (let me know if this is a correct way of thinking).

For the association I have:

class User < ApplicationRecord
  # Include default devise modules. Others available are:
  # :confirmable, :lockable, :timeoutable and :omniauthable
after_create :create_profile
has_one :profile
end
class Profile < ApplicationRecord
  belongs_to :user
end

I'm also using nested attributes for this so my routes look like this

user_profiles GET    /users/:user_id/profiles(.:format)                          profiles#index
                          POST   /users/:user_id/profiles(.:format)                          profiles#create
         new_user_profile GET    /users/:user_id/profiles/new(.:format)                      profiles#new
        edit_user_profile GET    /users/:user_id/profiles/:id/edit(.:format)                 profiles#edit
             user_profile GET    /users/:user_id/profiles/:id(.:format)                      profiles#show
                          PATCH  /users/:user_id/profiles/:id(.:format)                      profiles#update
                          PUT    /users/:user_id/profiles/:id(.:format)                      profiles#update
                          DELETE /users/:user_id/profiles/:id(.:format)                      profiles#destroy

So if I have to have a profile :id how am I suppose to figure out what the id will be. It will be different for each user since it increments for each profile that's created. The solution is probably obvious for most you guys out there but I've been banging my head against the wall for a bit trying to figure this out.

Thanks for any help :)