Created
March 13, 2012 19:23
-
-
Save underwhelmed/2030911 to your computer and use it in GitHub Desktop.
Example with wicked gem on create?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Account < ActiveRecord::Base | |
devise :database_autheticatable, :registerable, :recoverable, :rememberable, :trackable, :validatable | |
has_one :username | |
has_one :subscription | |
attr_accessible :email, :password, :password_confirmation, :remember_me, :full_name, :address_1, :address_2, :city, :state_province, :postal_code, :country | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class AccountController < Wicked::WizardController | |
steps :start, :info, :address, :billing, :review | |
def show | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Subscription < ActiveRecord::Base | |
belongs_to :plan | |
belongs_to: :account | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class UserName < ActiveRecord::Base | |
belongs_to :account | |
accepts_nested_attributes_for :account | |
end |
I like the pending idea. thanks!
happy to help !
^_^
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
So we need to store the data the user is input, but either keep a record that this is incomplete data in the system, or not save incomplete data.
Option 1
You could add a status field to your table then have a status of 'pending' and you can change all your validations to only run :if => pending? You can then have a sweeper that goes back and deletes all pending accounts that haven't been finalized for over 6 hours etc. This lets you save all of your data in the table, apply any column specific validations, and gives you full control over the process
Option 2
You can store all the values you need either in another table or in the session, or a data store such as redis/memecache/etc., though if you do this...you don't get any validations on your data. You then wait till the last step to actually save the data to the table.
It is much easier and much cleaner to store the data in the correct table, but with some kind of status/flag field to indicate that the account is not complete. I would recommend option 1.