Skip to content

Instantly share code, notes, and snippets.

View 1dolinski's full-sized avatar

Chris Dolinski 1dolinski

View GitHub Profile
require 'geocoder'
require 'csv'
require 'pry'
ROOT_LOCATION = "New York, New York"
FILELOAD = 'location.csv'
CSV_FILE_PATH = File.join(File.dirname(__FILE__), FILELOAD)
class InRadiusCSV
def username=(username)
#=> username == 1Boom
username.downcase
#=> 1boom
end
@user = User.new(params[:user])
#=> username is blank
id | post_id | user_id| created_at | updated_at |
+----+----------+--------+---------------------------+---------------------------+
| 8 | 7 | 1 | 2013-09-07 16:03:50 -0400 | 2013-09-07 16:03:50 -0400 |
| 9 | 7 | 2 | 2013-09-07 16:03:50 -0400 | 2013-09-07 16:03:50 -0400 |
| 10 | 7 | 3 | 2013-09-07 16:03:50 -0400 | 2013-09-07 16:03:50 -0400 |
| 12 | 11 | 1 | 2013-09-07 22:17:49 -0400 | 2013-09-07 22:17:49 -0400 |
| 13 | 11 | 6 | 2013-09-07 22:17:49 -0400 | 2013-09-07 22:17:49 -0400 |
| 14 | 12 | 1 | 2013-09-14 12:49:56 -0400 | 2013-09-14 12:49:56 -0400 |
| 15 | 12 | 3 | 2013-09-14 12:49:56 -0400 | 2013-09-14 12:49:56 -0400 |
get 'posts(/*title)' => 'posts#index', :as => :posts
render params.inspect
# =>{"controller"=>"posts", "action"=>"index", "title"=>"ok/cool/neat"}
# I would like it to render
# =>{"controller"=>"posts", "action"=>"index", "title"=>"["ok","cool","neat"]}
@1dolinski
1dolinski / gist:6588376
Last active December 23, 2015 05:39
I'd like to return the Posts that have user_id 2 and 3. This is my posting model. Posts have many user_ids through postings
id | post_id | user_id | created_at | updated_at |
+---+---------+--------+---------------------------+---------------------------+
| 1 | 7 | 1 | 2013-09-07 16:03:50 -0400 | 2013-09-07 16:03:50 -0400 |
| 2 | 7 | 2 | 2013-09-07 16:03:50 -0400 | 2013-09-07 16:03:50 -0400 |
| 3 | 7 | 3 | 2013-09-07 16:03:50 -0400 | 2013-09-07 16:03:50 -0400 |
| 4 | 8 | 2 | 2013-09-07 22:17:49 -0400 | 2013-09-07 22:17:49 -0400 |
| 5 | 8 | 3 | 2013-09-07 22:17:49 -0400 | 2013-09-07 22:17:49 -0400 |
| 6 | 8 | 6 | 2013-09-07 22:17:49 -0400 | 2013-09-07 22:17:49 -0400 |
| 7 | 12 | 3 | 2013-09-14 12:49:56 -0400 | 2013-09-14 12:49:56 -0400 |
[1] pry(#<#<Class:0x007fde0db9ae90>>)> params
=> {"posts"=>"", "controller"=>"news", "action"=>"index"}
[2] pry(#<#<Class:0x007fde0db9ae90>>)> request.params
=> {"posts"=>"", "controller"=>"news", "action"=>"index"}
[3] pry(#<#<Class:0x007fde0db9ae90>>)> request.url
=> "http://localhost:3000/news?posts=%23titlehere"
#encoding: utf-8
VALID_REGEX = /\A[a-zA-Z\s\d,-\?!&:0-9+\(\)]+\z\p{Hangul}\p{Han}/i
get ':user_id/posts/:post_id/' => "users#show", :controller => "users", :action => "show, :as => "user_home"
#now
user_home_path(current_user.id, @post.id)
#would like
user_home_path(current_user.id)
and have the current_user.posts.last.id to be the post that is returned
require 'spec_helper'
describe "Show page" do
subject { page }
describe "show page" do
let(:user) { create(:user) }
before { visit user_home_path}
binding.pry
it { should have_content(user.username.capitalize) }
1.9.3p194 :001 > a,b,c = [1,2,3]
=> [1, 2, 3]
1.9.3p194 :002 > a
=> 1
1.9.3p194 :003 > b
=> 2
1.9.3p194 :004 > c
=> 3