Class: PostingsController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- PostingsController
- Defined in:
- app/controllers/postings_controller.rb
Instance Method Summary (collapse)
- - (Object) create
- - (Object) delete_cover_picture
- - (Object) destroy
- - (Object) index
- - (Object) new
- - (Object) show
- - (Object) tags
- - (Object) update
Methods inherited from ApplicationController
Instance Method Details
- (Object) create
29 30 31 32 33 34 35 |
# File 'app/controllers/postings_controller.rb', line 29 def create if (@posting=@blog.create_posting(params[:posting],current_user)).errors.empty? redirect_to @blog, :notice => t(:posting_successfully_created) else render :new end end |
- (Object) delete_cover_picture
53 54 55 56 |
# File 'app/controllers/postings_controller.rb', line 53 def delete_cover_picture @posting.cover_picture.destroy @posting.save end |
- (Object) destroy
48 49 50 51 |
# File 'app/controllers/postings_controller.rb', line 48 def destroy @posting.destroy redirect_to @blog, :notice => t(:posting_successfully_destroyed) end |
- (Object) index
10 11 |
# File 'app/controllers/postings_controller.rb', line 10 def index end |
- (Object) new
25 26 27 |
# File 'app/controllers/postings_controller.rb', line 25 def new @posting = @blog.postings.build(:user => current_user) end |
- (Object) show
22 23 |
# File 'app/controllers/postings_controller.rb', line 22 def show end |
- (Object) tags
13 14 15 16 17 18 19 20 |
# File 'app/controllers/postings_controller.rb', line 13 def respond_to do |format| format.json { render :json => Posting..reject{|t| t !~ /#{params[:q]}/i} .map{|tag| [:id =>tag, :name => tag]}.flatten } end end |
- (Object) update
37 38 39 40 41 42 43 44 45 46 |
# File 'app/controllers/postings_controller.rb', line 37 def update if @posting.update_attributes(params[:posting]) @posting..each do |att| att.save! end redirect_to @blog, :notice => t(:posting_successfully_updated) else render :edit end end |