Skip to content

Commit

Permalink
[add]
Browse files Browse the repository at this point in the history
  • Loading branch information
mi-373 committed Apr 10, 2019
1 parent 3558d9b commit cfabe0b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
8 changes: 8 additions & 0 deletions app/controllers/contents_controller.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
class ContentsController < ApplicationController
protect_from_forgery except: [:auto_tweet]
#新規作成
def create
@content = Content.new(content_params)
Expand All @@ -20,6 +21,13 @@ def tweet
redirect_to success_path
end

#定期ツイート
def auto_tweet
random_id = Content.all.map(&:id).sample
twitter = TwitterApi.new
twitter.tweet(random_id)
end

def new
@content = Content.new
end
Expand Down
1 change: 1 addition & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
root 'contents#home'
get '/success', to:'contents#success', as:'success'
match '/tweet', to:'contents#tweet', via: [:post], as: 'tweet'
match '/auto_tweet', to:'contents#auto_tweet', via: [:post], as: 'auto_tweet'
resources :contents, except:[:show, :edit, :update]
end

0 comments on commit cfabe0b

Please sign in to comment.