diff --git a/README.md b/README.md index d29f0ed..6440205 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ -twitter-clone +Twetter ============= -This is the sample Twitter Clone code base for Thinkful's Ruby on Rails course. +This is the sample version of Twetter, a basic clone of the most popular micro-blogging site, produced for Thinkful's Ruby on Rails course. Before Beginning ------------- @@ -24,15 +24,15 @@ Getting Started ```sh # Clone the repository -git clone git@github.com:Thinkful/twitter-clone.git +git clone git@github.com:Thinkful/twetter.git -cd ./twitter-clone +cd ./twetter # Install the required gems bundle install # Generate a new config/initializers/secret_token.rb file. -echo "TwitterClone::Application.config.secret_key_base = '`bundle exec rake secret`'" > config/initializers/secret_token.rb +echo "Twetter::Application.config.secret_key_base = '`bundle exec rake secret`'" > config/initializers/secret_token.rb # Set up the database bundle exec rake db:create db:migrate db:test:prepare @@ -50,7 +50,7 @@ Seeds ```sh bundle exec rake seed:users # Create 20 users -bundle exec rake seed:tweets # Create 5 tweets for each user +bundle exec rake seed:twets # Create 5 twets for each user ``` If you'd like to log in as one of your recently seeded users, use the rails console to diff --git a/Rakefile b/Rakefile index 9be8df9..4949079 100644 --- a/Rakefile +++ b/Rakefile @@ -3,4 +3,4 @@ require File.expand_path('../config/application', __FILE__) -TwitterClone::Application.load_tasks +Twetter::Application.load_tasks diff --git a/app/assets/images/twetter-logo.png b/app/assets/images/twetter-logo.png new file mode 100644 index 0000000..87fccbc Binary files /dev/null and b/app/assets/images/twetter-logo.png differ diff --git a/app/assets/javascripts/tweets.js.coffee b/app/assets/javascripts/twets.js.coffee similarity index 100% rename from app/assets/javascripts/tweets.js.coffee rename to app/assets/javascripts/twets.js.coffee diff --git a/app/assets/stylesheets/style.css b/app/assets/stylesheets/style.css index 6b965ad..221a8e2 100644 --- a/app/assets/stylesheets/style.css +++ b/app/assets/stylesheets/style.css @@ -42,8 +42,8 @@ nav { } .bird-topbar-blue { - background-image: url(../assets/twitter_web_sprite_icons.png); - background-position: -80px 0; + background-image: url(../assets/twetter-logo.png); + background-position: 0 0; width: 24px; height: 21px; float: left; diff --git a/app/assets/stylesheets/tweets.css.scss b/app/assets/stylesheets/twets.css.scss similarity index 64% rename from app/assets/stylesheets/tweets.css.scss rename to app/assets/stylesheets/twets.css.scss index 17d3855..cc2a213 100644 --- a/app/assets/stylesheets/tweets.css.scss +++ b/app/assets/stylesheets/twets.css.scss @@ -1,3 +1,3 @@ -// Place all the styles related to the Tweets controller here. +// Place all the styles related to the Twets controller here. // They will automatically be included in application.css. // You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/controllers/tweets_controller.rb b/app/controllers/tweets_controller.rb deleted file mode 100644 index f7102b4..0000000 --- a/app/controllers/tweets_controller.rb +++ /dev/null @@ -1,57 +0,0 @@ -class TweetsController < ApplicationController - # All actions in this controller require the presence of an authenticated user. - before_filter :authenticate_user! - - # GET /tweets - # - # This action uses the #get_tweets method to set the @tweets instance variable. - # - # @tweets # => All tweets defaultly shown to the authenticated user. - # - def index - get_tweets - end - - # POST /tweets - # - # Used to create a new tweet for the authenticated user based on the data passed - # in params[:tweet]. If the tweet is created successfully, a success message is - # set and we are directed to the index action. Otherwise, an error message is set, - # the tweets visible to the authenticated user are loaded into @tweets and the index - # view template is displayed. - # - # @tweet # => The newly created (or attempted) tweet. - # @tweets # => (only set if the tweet was not created) All tweets defaultly shown - # to the authenticated user. - # - # - def create - @tweet = current_user.tweets.create(tweet_params) - if @tweet.valid? - flash[:success] = "Your tweet was shared" - redirect_to :action => :index and return - else - get_tweets - flash[:error] = "Your tweet could not be saved" - render :action => :index and return - end - end - - private - - # Sets the @tweets instance variable to all tweets viewable by the current user - def get_tweets - @tweets = current_user.all_tweets - end - - # http://guides.rubyonrails.org/action_controller_overview.html#strong-parameters - # - # This method uses Strong Parameters to ensure that the data passed by the user - # is appropriate. If params[:tweet] does not exist or contains any key / value - # pairs other then :content, an error will be raised and the page will return - # a 400 'Bad Request' HTML response code. - # - def tweet_params - params.require(:tweet).permit(:content) - end -end diff --git a/app/controllers/twets_controller.rb b/app/controllers/twets_controller.rb new file mode 100644 index 0000000..2266efd --- /dev/null +++ b/app/controllers/twets_controller.rb @@ -0,0 +1,57 @@ +class TwetsController < ApplicationController + # All actions in this controller require the presence of an authenticated user. + before_filter :authenticate_user! + + # GET /twets + # + # This action uses the #get_twets method to set the @twets instance variable. + # + # @twets # => All twets defaultly shown to the authenticated user. + # + def index + get_twets + end + + # POST /twets + # + # Used to create a new twet for the authenticated user based on the data passed + # in params[:twet]. If the twet is created successfully, a success message is + # set and we are directed to the index action. Otherwise, an error message is set, + # the twets visible to the authenticated user are loaded into @twets and the index + # view template is displayed. + # + # @twet # => The newly created (or attempted) twet. + # @twets # => (only set if the twet was not created) All twets defaultly shown + # to the authenticated user. + # + # + def create + @twet = current_user.twets.create(twet_params) + if @twet.valid? + flash[:success] = "Your twet was shared" + redirect_to :action => :index and return + else + get_twets + flash[:error] = "Your twet could not be saved" + render :action => :index and return + end + end + + private + + # Sets the @twets instance variable to all twets viewable by the current user + def get_twets + @twets = current_user.all_twets + end + + # http://guides.rubyonrails.org/action_controller_overview.html#strong-parameters + # + # This method uses Strong Parameters to ensure that the data passed by the user + # is appropriate. If params[:twet] does not exist or contains any key / value + # pairs other then :content, an error will be raised and the page will return + # a 400 'Bad Request' HTML response code. + # + def twet_params + params.require(:twet).permit(:content) + end +end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index d12f55f..af78764 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -48,8 +48,8 @@ def active_class(name) case name when "Follow" then controller_name == 'follows' ? 'active' : '' - when "Tweet" then - controller_name == 'tweets' ? 'active' : '' + when "Twet" then + controller_name == 'twets' ? 'active' : '' end end diff --git a/app/helpers/tweets_helper.rb b/app/helpers/tweets_helper.rb deleted file mode 100644 index 6b7d657..0000000 --- a/app/helpers/tweets_helper.rb +++ /dev/null @@ -1,2 +0,0 @@ -module TweetsHelper -end diff --git a/app/helpers/twets_helper.rb b/app/helpers/twets_helper.rb new file mode 100644 index 0000000..b9eb842 --- /dev/null +++ b/app/helpers/twets_helper.rb @@ -0,0 +1,2 @@ +module TwetsHelper +end diff --git a/app/models/tweet.rb b/app/models/twet.rb similarity index 63% rename from app/models/tweet.rb rename to app/models/twet.rb index cf01ca4..9891cf8 100644 --- a/app/models/tweet.rb +++ b/app/models/twet.rb @@ -1,11 +1,11 @@ -class Tweet < ActiveRecord::Base +class Twet < ActiveRecord::Base belongs_to :user validates :content, :presence => true, :length => { :minimum => 2, :maximum => 140 } validates :user, :presence => true - # Gets all tweets made by the users referenced by the ids passed, starting with the - # most recent tweet made. + # Gets all twets made by the users referenced by the ids passed, starting with the + # most recent twet made. # def self.by_user_ids(*ids) where(:user_id => ids.flatten.compact.uniq).order('created_at DESC') diff --git a/app/models/user.rb b/app/models/user.rb index 5202af8..1421a84 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -4,7 +4,7 @@ class User < ActiveRecord::Base :recoverable, :rememberable, :trackable, :validatable has_many :follows - has_many :tweets + has_many :twets validates :name, :presence => true validates :username, :presence => true, :uniqueness => true @@ -15,10 +15,10 @@ def self.all_except(user) User.where(arel_table[:id].not_eq(user.id)).order(:name) end - # Leverages Tweet.by_user_ids to return all tweets created by this user + # Leverages Twet.by_user_ids to return all twets created by this user # and all users that this user follows. # - def all_tweets - Tweet.by_user_ids(id, *follows.map(&:following_id)) + def all_twets + Twet.by_user_ids(id, *follows.map(&:following_id)) end end diff --git a/app/views/follows/index.html.erb b/app/views/follows/index.html.erb index c6ca162..3c9a743 100644 --- a/app/views/follows/index.html.erb +++ b/app/views/follows/index.html.erb @@ -6,7 +6,7 @@
Twitter accounts in alpabetical order.
+Twetter accounts in alpabetical order.