Ruby on Rails - Single Sign Up and Login Form for Two Different User Types and handling the Session -


i'm pretty new ruby on rails, right i'm trying set simple platform create events, manage events, , purchase tickets events. have 2 different user types:

manager: has_many: events  (with params): email password organization_name   fan: has_many: tickets  (with params): email password name cell_phone 

i have 2 different partials containing sign-up forms both managers , fans. thought process right have param called @is_manager in session allows sign-up form dynamically hide/reveal partials , handle logic in controller.

the sign-in form both models identical, can both login using emails , passwords. current thought either include additional checkbox filters attempted logins either fan or manager database, or require emails unique across both databases.

i've looked @ large number of other stack overflow questions, , have looked devise (which cautioned against while still don't have strong handling of ruby on rails), jquery solutions dynamically changing session param, haven't found solution feel applies me.

thoughts?

(my current sign-up form code below:)

<h1>signup</h1>    <h3>are manager?</h3>   <%= link_to_function "yes", "magic_javascript_function" %>   <%= link_to_function "no", "magic_javascript_function" %>  <%= form_for :session, url: signup_path, method: :post |f| %>   <%= render 'manager_signup', :f => f if @is_manager %>   <%= render 'user_signup', :f => f unless @is_manager %>   <%= f.submit 'submit', class: "btn btn-primary" %> <% end %> 

if new ror highly advise going rails tutorial michael hartl's railstutorial.org.

i recomend tutorial because shows how create user model login sessions etc. without using devise or cancan , gives excelent insight programs used , how work can use them later.

in regards specific case argue this: if member has acted manger wants go managers event. need separate fan account. alternatively if member has been fan wants organize local event garage band.

see going this. might best login/signup page agnostic towards these roles.

where use these roles in relationships here this

user.rb     has_many: events     has_many: tickets  event.rb     belongs_to: manager, class_name: "user"     has_many: tickets  ticket.rb     belongs_to: event     belongs_to: fan, class_name: "user" 

check belongs_to api if gives trouble may need explicitly set foreign key.


Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -