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 Deal < ActiveRecord::Base | |
# Associations | |
has_and_belongs_to_many :stores | |
belongs_to :user, :class_name => "User", :foreign_key => "merchant_id" | |
has_many :punches | |
# To-do: Validations | |
# Add validations on the deals model | |
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
# The below file was used in a project that required the use of CanCan Gem | |
# Author: Jasdeep Narang | |
class Ability | |
include CanCan::Ability | |
def initialize(user) | |
user ||= User.new # guest user (not logged in) | |
if user.role? :admin |
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 StoresController < ApplicationController | |
before_filter :authenticate_user! | |
def index | |
@user = current_user | |
@stores = current_user.stores | |
end | |
def new | |
@user = current_user | |
@store = current_user.stores.build |
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 SessionsController < Devise::SessionsController | |
skip_before_filter :verify_authenticity_token | |
def create | |
#resource = warden.authenticate!(:scope => resource_name, :recall => :failure) | |
resource = warden.authenticate!(:scope => resource_name, :recall => "sessions#failure" ) | |
if !resource.blank? | |
flash[:notice] = "Signed in successfully!" | |
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 ApiController < ApplicationController | |
before_filter :authenticate_user! | |
skip_before_filter :verify_authenticity_token | |
def store_coordinates | |
@store = Geocoder.search(params[:address]) | |
render :json => @store[0].geometry | |
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 UsersController < ApplicationController | |
def create | |
@user = User.new(params[:user]) | |
@fbUser = session[:fbUser] | |
if @user.save | |
flash[:notice] = "Success" | |
#redirect_to :action => "success" | |
redirect_to :root | |
else | |
flash[:error] = "The below errors prevented your request from being processed:" |
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
gem 'therubyracer' # add this |
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
# If you are facing such an Error while installing/working with the aws-s3 gem | |
# /config/initializers/s3.rb:1:in `<top (required)>': uninitialized constant AWS (NameError) | |
# try adding this to your Gemfile instead.. | |
gem 'aws-s3', :require => 'aws/s3' | |
# I was having this issue on Mac OS X Lion with aws-s3 gem 0.6.2 |
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
cd ~/src | |
git clone git://github.com/masterkain/ImageMagick-sl.git | |
cd ImageMagick-sl | |
sh install_im.sh | |
sudo gem install rmagick |
NewerOlder