Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@chckと@knjcode! #8

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

# Ignore bundler config.
/.bundle
vendor/bundle
.idea/

# Ignore the default SQLite database.
/db/*.sqlite3
Expand Down
3 changes: 3 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ gem 'sass-rails', '~> 4.0.0'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.0.0'
gem 'jquery-rails'

gem 'twitter'

# gem 'turbolinks'
# gem 'jbuilder', '~> 1.2'

Expand Down
11 changes: 11 additions & 0 deletions app/controllers/static_pages_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,15 @@ def home

def help
end

def analyze
@id = params[:twitter_id]
@client = Twitter::REST::Client.new do |config|
config.consumer_key = ENV["CONSUMER_KEY"]
config.consumer_secret = ENV["CONSUMER_SECRET"]
config.access_token = ENV["ACCESS_TOKEN"]
config.access_token_secret = ENV["ACCESS_TOKEN_SECRET"]
end
@texts = @client.user(@id).description
end
end
2 changes: 2 additions & 0 deletions app/views/static_pages/analyze.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<%= @id %>
<%= @texts %>
3 changes: 2 additions & 1 deletion app/views/static_pages/home.html.erb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<form>
<form action="/analyze" method="get">
<input type="text" placeholder="twitter id" id="twitter_id" name="twitter_id">
<button>ボタン</button>
</form>
1 change: 1 addition & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
Yochigaya::Application.routes.draw do
root 'static_pages#home'
get 'static_pages/help'
match '/analyze', to: 'static_pages#analyze', via: 'get'
# The priority is based upon order of creation: first created -> highest priority.
# See how all your routes lay out with "rake routes".

Expand Down