Class: BlogsController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- BlogsController
- Defined in:
- app/controllers/blogs_controller.rb
Instance Method Summary (collapse)
- - (Object) create
-
- (Object) delete_cover_picture
GET /blogs/:id/delete_cover_picture.
-
- (Object) destroy
DELETE /blogs/:id DELETE /blogs/:id.xml.
- - (Object) edit
- - (Object) index
- - (Object) new
-
- (Object) show
Show all postings for this blog.
- - (Object) update
Methods inherited from ApplicationController
Instance Method Details
- (Object) create
43 44 45 46 47 48 49 50 |
# File 'app/controllers/blogs_controller.rb', line 43 def create @blog = Blog.new(params[:blog]) if @blog.save redirect_to @blog, :notice => t(:blog_successfully_created) else render :new end end |
- (Object) delete_cover_picture
GET /blogs/:id/delete_cover_picture
83 84 85 86 87 |
# File 'app/controllers/blogs_controller.rb', line 83 def delete_cover_picture @blog = scoped_find(params[:id]) @blog.cover_picture.destroy @blog.save end |
- (Object) destroy
DELETE /blogs/:id DELETE /blogs/:id.xml
73 74 75 76 77 78 79 80 |
# File 'app/controllers/blogs_controller.rb', line 73 def destroy @blog = scoped_find(params[:id]) @blog.destroy respond_to do |format| format.html { redirect_to(blogs_url, :notice => t(:blog_successfully_destroyed)) } format.xml { head :ok } end end |
- (Object) edit
52 53 54 |
# File 'app/controllers/blogs_controller.rb', line 52 def edit @blog = scoped_find(params[:id]) end |
- (Object) index
7 8 9 10 11 12 13 14 15 16 17 |
# File 'app/controllers/blogs_controller.rb', line 7 def index @blogs = scoped_blogs.all.paginate( :page => params[:page], :per_page => APPLICATION_CONFIG[:pages_per_page] || 5 ) respond_to do |format| format.html # index.html.erb format.xml { render :xml => @blogs } end end |
- (Object) new
39 40 41 |
# File 'app/controllers/blogs_controller.rb', line 39 def new @blog = Blog.new end |
- (Object) show
Show all postings for this blog
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'app/controllers/blogs_controller.rb', line 20 def show @blog = scoped_find(params[:id]) unless current_user @postings = @blog.scoped_postings({:is_draft => draft_mode}).public.desc(:created_at)\ .paginate(:page => params[:page],:per_page => CONSTANTS['paginate_postings_per_page'].to_i) else @postings = @blog.scoped_postings({:is_draft => draft_mode}).addressed_to(current_user.id).desc(:created_at)\ .paginate(:page => params[:page],:per_page => CONSTANTS['paginate_postings_per_page'].to_i) end respond_to do |format| format.js { @path = blog_path(@blog, :page => (params[:page] ? (params[:page].to_i+1) : 2) ) } format.html # index.html.erb format.xml { render :xml => @blog } end end |
- (Object) update
56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'app/controllers/blogs_controller.rb', line 56 def update @blog = scoped_find(params[:id]) respond_to do |format| if @blog.update_attributes(params[:blog]) format.html { redirect_to(@blog, :notice => t(:blog_successfully_updated)) } format.xml { head :ok } else format.html { render :action => "edit" } format.xml { render :xml => @blog.errors, :status => :unprocessable_entity } end end end |