Roman Storm
Joined
Activity
Basically I did STI on User model, and made it working and then removed whatever I did, installed rolify + pundit :-)
Posted in Just sharing: Squash your migrations
I've gone into problem when my test db is using sqlite and I use postgres in prod
Sqlite doesn't have inet
attribute like postgres and I went into some old migration that I don't use anymore.
So,
Clean up your old migrations with https://github.com/jalkoby/squasher
Easy your time on new envs + remove unneccessary create_table, drop_table migrations which happen all the time when we try to implement something
Figured it out. It was the problem that I didn't permit
and sanitized params, even though they were exactly the same in order to User.new user.save
Lets say we have a Company model which accepts_nested_attributes_for User (devise Model)
How do we Save both a company and User model having that a Company has_many :users and a User belongs to a Company???
Users has :confirmable option as well.
so after successful creation of those, we should have company with company_id, a user with company_id as well assigned to him.
Feels I'm getting close
devise_for :agents
devise_for :companies
rails g devise User
class Company < User
end
class Agent < User
end
in application_controller
put this:
devise_group :user, contains: [:agent, :company]
so if using confirmable or something, we still can use current_user
or current_agent
Maybe using this one somehow can help?
https://github.com/plataformatec/devise/wiki/How-To:-Customize-routes-to-user-registration-pages
What if a use case the following:
Generate 1 devise Account model
Create 2 Other Models: User and Member
User and Member both inherit from Account
Member has multiple roles(owner, employee, etc.)
Member is representative of a Company, so when a company signs up,
we Create a Member model + accept nested attributes and build a Company model from there
**Update:
How to have proper devise routes setup for 2 models and tight them to 1 model? I'm trying to do it without any luck so far.
Chris what do you think of this?
http://www.rubydoc.info/github/plataformatec/devise/master/Devise/Controllers/Helpers/ClassMethods:devise_group
thank you Chris!
Posted in how scrabe data every day
python has much better eco system for scrapping data
http://scrapy.org/
but mechanize will work as well as https://github.com/felipecsl/wombat
Scenario:
Implement a registration with multiple steps and after all is complete, display "We will approve your application" at the end and wait when an internal admin (only to owners of the app) will approve the account
For implementing admin thing is documented here:
https://github.com/plataformatec/devise/wiki/How-To:-Require-admin-to-activate-account-before-sign_in
but I can't see good pattern for implementing multi step sign up