This file contains hidden or 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 LoginController < ApplicationController | |
| skip_before_filter :check_authentication, :only => :index | |
| def index | |
| user = User.find_by_email(params[:email]) | |
| if user and user.authenticate(params[:password]) | |
| respond_with user | |
| end | |
| end | |
This file contains hidden or 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 LoginController < ApplicationController | |
| skip_before_filter :check_authentication, :only => :index | |
| def index | |
| user = User.find_by_email(params[:email]) | |
| if user && user.authenticate(params[:password]) | |
| respond_with user | |
| else | |
| render | |
| end |
This file contains hidden or 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 LoginController < ApplicationController | |
| skip_before_filter :check_authentication, :only => :index | |
| def index | |
| @user = User.find_by_email(params[:email]) | |
| if @user && @user.authenticate(params[:password]) | |
| render 'login/index' | |
| else | |
| record_not_found | |
| end |
This file contains hidden or 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
| { | |
| "user" : { | |
| "first_name": "John", | |
| "last_name": "Doe", | |
| "email": "[email protected]", | |
| "mobile": "9876545678", | |
| "locality": "Goregaon", | |
| "city": "Mumbai", | |
| "user_type": "advisor", | |
| } |
This file contains hidden or 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 CreateInquiries < ActiveRecord::Migration | |
| def change | |
| create_table :inquiries, id: false do |t| | |
| t.primary_key :id, :uuid, :default => 'uuid_generate_v1()' | |
| t.belongs_to :contact | |
| t.string :inquiry_type | |
| t.hstore :metadata | |
| t.string :locality | |
| t.string :city | |
| t.uuid :added_by |
This file contains hidden or 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
| module Contactable | |
| def self.set_contact(contact) | |
| @contact = Contact.find_by_email(contact[:email]) | |
| @contact = Contact.create!(contact) unless @contact.exists? | |
| end | |
| def self.get_contact | |
| @contact | |
| end | |
| end |
This file contains hidden or 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
| require 'spec_helper' | |
| require 'faker' | |
| describe Stampable do | |
| it "throws error if stamp and contact is unset" do | |
| expect { FactoryGirl.create(:user) }.to raise_error | |
| end | |
| it "can be saved if contact and stamp were set" do | |
| user = FactoryGirl.build(:user) |
This file contains hidden or 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
| require 'spec_helper' | |
| describe UsersController do | |
| render_views | |
| describe 'franchisee actions on users' do | |
| before :each do | |
| fr = FactoryGirl.build(:user, user_type: 'franchisee') | |
| fr.set_stamp(FactoryGirl.build(:stamp), FactoryGirl.build(:contact, email: '[email protected]')) | |
| fr.save |
This file contains hidden or 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
| User.includes(stamp: [:contact]).where(:user_type => 'franchisee').joins(:stamp).joins(:children).group("users.id, stamps.status").count("stamps.status") |
This file contains hidden or 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
| users = Arel::Table.new(:users) | |
| stamps = Arel::Table.new(:stamps) | |
| contacts = Arel::Table.new(:contacts) | |
| children = users.alias | |
| query = users.where(users[:user_type].eq('franchisee')) | |
| query = query.join(stamps).on(users[:id].eq(stamps[:stampable_id])) | |
| query = query.join(contacts).on(contacts[:id].eq(stamps[:contact_id])) | |
| query = query.join(children).on(users[:id].eq(children[:parent_id])) | |
| query = query.join(stamps).on(children[:id].eq(stamps[:stampable_id])) |