Roman Storm

Joined

920 Experience
0 Lessons Completed
1 Question Solved

Activity

Posted in Build a Devise Model in another controller

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

Posted in Build a Devise Model in another controller

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

Posted in Build a Devise Model in another controller

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.

Posted in Devise with multiple User Models with single login form

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

Posted in Devise with multiple User Models with single login form

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.

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

logo Created with Sketch.

Ruby on Rails tutorials, guides, and screencasts for web developers learning Ruby, Rails, Javascript, Turbolinks, Stimulus.js, Vue.js, and more. Icons by Icons8

© 2020 GoRails, LLC. All rights reserved.