2012-12-17 05:50:23 -05:00
|
|
|
# Dummy Controllers
|
|
|
|
class ApplicationController < ActionController::Base
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
class ArticlesController < ApplicationController
|
|
|
|
|
2012-12-19 01:59:38 -05:00
|
|
|
def index
|
|
|
|
@articles = Article.all
|
|
|
|
js_callback :params => {:article_count => @articles.size}
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2012-12-17 05:50:23 -05:00
|
|
|
def show
|
|
|
|
@article = Article.find params[:id]
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def new
|
|
|
|
@article = Article.new
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def create
|
|
|
|
@article = Article.new params[:article]
|
2012-12-19 01:59:38 -05:00
|
|
|
|
2012-12-17 05:50:23 -05:00
|
|
|
if @article.save
|
|
|
|
redirect_to @article
|
|
|
|
else
|
2012-12-19 01:59:38 -05:00
|
|
|
js_callback :new
|
|
|
|
render :new
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def edit
|
|
|
|
@article = Article.find params[:id]
|
|
|
|
render :new
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def update
|
|
|
|
@article = Article.find params[:id]
|
|
|
|
|
|
|
|
if @article.update_attributes params[:article]
|
2012-12-17 05:50:23 -05:00
|
|
|
js_callback false
|
2012-12-19 01:59:38 -05:00
|
|
|
redirect_to @article
|
|
|
|
else
|
|
|
|
js_callback :controller => :articles, :action => :edit
|
2012-12-17 05:50:23 -05:00
|
|
|
render :new
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
2012-12-21 03:29:15 -05:00
|
|
|
|
|
|
|
module SampleNamespace
|
|
|
|
class CategoriesController < ApplicationController
|
|
|
|
def index
|
2013-01-16 12:55:09 -05:00
|
|
|
@categories = Category.all
|
2012-12-21 03:29:15 -05:00
|
|
|
end
|
2013-01-18 21:27:51 -05:00
|
|
|
|
|
|
|
|
|
|
|
def new
|
|
|
|
@category = Category.new
|
|
|
|
js_callback :index
|
|
|
|
end
|
2012-12-21 03:29:15 -05:00
|
|
|
end
|
|
|
|
end
|