Skip to content

Instantly share code, notes, and snippets.

@jasdeepsingh
Created November 3, 2011 00:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jasdeepsingh/1335369 to your computer and use it in GitHub Desktop.
Save jasdeepsingh/1335369 to your computer and use it in GitHub Desktop.
Stores Controller
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
end
def create
@store = current_user.stores.build(params[:store])
#@store.merchant_id = current_user.id
respond_to do |format|
if @store.save
format.html { redirect_to users_stores_path, notice: "Store Added Successfully!" }
format.json { render json: @store, status: :crteated, location: @store}
else
format.html { render action: "new" }
end
end
end
def destroy
@store = Store.find(params[:id])
respond_to do |format|
if @store.destroy
format.html { redirect_to users_stores_path, notice: "Store delete Successfully!" }
format.json { render json: @store, status: :destroyed, location: @store}
else
format.html { render action: "index" }
end
end
end
def store_map
@store = current_user.stores.find(params[:store_id])
render :layout => false
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment