1
0
Fork 0
mirror of https://github.com/kbparagua/paloma synced 2023-03-27 23:21:17 -04:00
paloma/spec/sample_app/controllers.rb

55 lines
884 B
Ruby
Raw Normal View History

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