gitflow | git |
---|---|
git flow init |
git init |
git commit --allow-empty -m "Initial commit" |
|
git checkout -b develop master |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class UserController < ApplicationController | |
def index | |
@users = User.all | |
end | |
def create | |
@user = User.new(user_params) | |
if @user.save | |
redirect_to users_path | |
else |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
HTTP status code symbols for Rails | |
Thanks to Cody Fauser for this list of HTTP responce codes and their Ruby on Rails symbol mappings. | |
Status Code Symbol | |
1xx Informational | |
100 :continue | |
101 :switching_protocols | |
102 :processing |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module TweetsHelper | |
def build_tweets_hash tweets | |
@tweets_array = [] | |
tweets.each do |tweet| | |
tweet_hash = { | |
user: tweet['user']['screen_name'], | |
user_profile: ENV['TWITTER_URL'] + tweet['user']['id'].to_s, | |
followers_count: tweet['user']['followers_count'], | |
retweets: tweet['retweet_count'], |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class TweetsController < ApplicationController | |
def most_relevants | |
process_most_relevants | |
end | |
def most_mentions | |
process_most_mentions | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Api | |
class TweetsApiManager | |
def initialize options={} | |
end | |
def execute | |
connect_to_twitter_api(ENV['API_ENDPOINT']) | |
elect_tweets | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
operations = Operation.all | |
states = CountryState.all | |
states.each do |s| | |
operations.each do |operation| | |
next if (operation.name == "Teste" || operation.name == "teste" || operation.name == "TESTE") | |
case s.name | |
when "Amazonas" | |
operation.country_state_id = 1 if operation.name == "CDD MANAUS" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def list_favorite_bars bar_id | |
@favorite_bars = get_favorite_bars(params[:bar_id]) | |
respond_to do |format| | |
format.json { render :json => @favorite_bars} | |
end | |
end | |
private | |
def get_favorite_bars bar_id |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def list | |
## FILTER | |
@bars = Bar.where("latitude IS NOT NULL").where("longitude IS NOT NULL") | |
@bars = @bars.running_in(true) | |
if params[:search_term] | |
search_name = @bars.like_name(params[:search_term]) | |
search_district = @bars.district_by_name(params[:search_term]) | |
joined = search_name + search_district | |
joined_ids = joined.uniq.map{|bar| bar.id} | |
@bars = Bar.where(id:joined_ids) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def show | |
load_deals unless mobile_device? || request.format == :js | |
@deal_weekday = DealWeekday.by_weekday(Weekday.from_slug(params[:weekday])).by_slug(params[:slug]).active.first | |
if !@deal_weekday || !@deal_weekday.active | |
flash[:error] = '<strong>Desculpe!</strong> Não encontramos a pedida que você solicitou.' | |
redirect_to home_path(@city.slug) | |
return false | |
end |
NewerOlder