소스 검색

Added posts controller; near action to show posts near a point

master
Adrian Short 12 년 전
부모
커밋
4c14a86955
8개의 변경된 파일44개의 추가작업 그리고 0개의 파일을 삭제
  1. +3
    -0
      app/assets/javascripts/posts.js.coffee
  2. +3
    -0
      app/assets/stylesheets/posts.css.scss
  3. +10
    -0
      app/controllers/posts_controller.rb
  4. +2
    -0
      app/helpers/posts_helper.rb
  5. +11
    -0
      app/views/posts/near.html.haml
  6. +2
    -0
      config/routes.rb
  7. +9
    -0
      test/functional/posts_controller_test.rb
  8. +4
    -0
      test/unit/helpers/posts_helper_test.rb

+ 3
- 0
app/assets/javascripts/posts.js.coffee 파일 보기

@@ -0,0 +1,3 @@
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/

+ 3
- 0
app/assets/stylesheets/posts.css.scss 파일 보기

@@ -0,0 +1,3 @@
// Place all the styles related to the posts controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/

+ 10
- 0
app/controllers/posts_controller.rb 파일 보기

@@ -0,0 +1,10 @@
class PostsController < ApplicationController
def near
@posts = Post.near(params[:lat].to_f, params[:lng].to_f, params[:radius].to_f)

respond_to do |format|
format.html # near.html.erb
format.json { render json: @posts }
end
end
end

+ 2
- 0
app/helpers/posts_helper.rb 파일 보기

@@ -0,0 +1,2 @@
module PostsHelper
end

+ 11
- 0
app/views/posts/near.html.haml 파일 보기

@@ -0,0 +1,11 @@
%h1 Posts#near

%table
- @posts.each do |p|
%tr
%td= link_to p.title, p.url
%td= p.loc['lat']
%td= p.loc['lng']
%td
- unless p.published.nil?
= p.published.strftime("%d %b %Y %H:%M")

+ 2
- 0
config/routes.rb 파일 보기

@@ -1,4 +1,6 @@
Apollo::Application.routes.draw do
get "posts/near"

resources :feeds do
member do
get 'fetch'


+ 9
- 0
test/functional/posts_controller_test.rb 파일 보기

@@ -0,0 +1,9 @@
require 'test_helper'

class PostsControllerTest < ActionController::TestCase
test "should get near" do
get :near
assert_response :success
end

end

+ 4
- 0
test/unit/helpers/posts_helper_test.rb 파일 보기

@@ -0,0 +1,4 @@
require 'test_helper'

class PostsHelperTest < ActionView::TestCase
end

불러오는 중...
취소
저장