Created
November 3, 2011 00:04
-
-
Save jasdeepsingh/1335369 to your computer and use it in GitHub Desktop.
Stores Controller
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 | |
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