Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
mokevnin committed Jun 23, 2013
1 parent 0ae42d2 commit a80f0ae
Show file tree
Hide file tree
Showing 17 changed files with 53 additions and 26 deletions.
9 changes: 0 additions & 9 deletions TODO.md
Original file line number Diff line number Diff line change
@@ -1,9 +0,0 @@
* add badges
* haml
* twitter-bootstrap-rails
* User (login, email, password_digest, state)
* user crud in admin namespace
* user list on frontend
* registration
* facebook registration (omniauth)
* heroku
2 changes: 1 addition & 1 deletion app/controllers/web/passwords_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def update
return redirect_to(root_path) unless params[:reset_password_token]
user = User.where(params.slice(:reset_password_token)).first!
@user = user.becomes(UserPasswordEditType)
if @user.update_attributes(params[:user])
if @user.update(params[:user])
f(:success)
redirect_to root_path
else
Expand Down
18 changes: 11 additions & 7 deletions app/controllers/web/topics_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,27 @@ def new
@topic = current_user.topics.build
end

def edit
@topic = current_user.topics.find(params[:id])
end

def create
topic = AccountTopicType.new(params[:topic])
topic.creator = current_user
if topic.save
@topic = AccountTopicType.new(params[:topic])
@topic.creator = current_user
if @topic.save
f(:success)
redirect_to topic_path(topic)
redirect_to edit_topic_path(@topic)
else
f(:error)
render :new
end
end

def update
@topic = current_user.topics.find(params[:id])
@topic = @topic.becomes(AccountTopicType)
if @topic.update_attributes(params[:topic])
redirect_to action: :index
if @topic.update(params[:topic])
f(:success)
redirect_to edit_topic_path(@topic)
else
render :new
end
Expand Down
5 changes: 5 additions & 0 deletions app/controllers/web/users/comments_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class Web::Users::CommentsController < Web::Users::ApplicationController
def index
@comments = resource_user.topic_comments.page(params[:page])
end
end
2 changes: 1 addition & 1 deletion app/controllers/web/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ def index
end

def show
@user = User.active.find(params[:id])
@user = User.active.where(login: params[:id]).first!
end

def new
Expand Down
2 changes: 2 additions & 0 deletions app/helpers/web/users/comments_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
module Web::Users::CommentsHelper
end
2 changes: 1 addition & 1 deletion app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ class User < ActiveRecord::Base

has_many :authorizations, dependent: :destroy
has_many :topics, foreign_key: :creator_id, dependent: :restrict_with_exception
has_many :topic_comments, dependent: :restrict_with_exception
has_many :topic_comments, class_name: 'Topic::Comment', dependent: :restrict_with_exception

validates :email, uniqueness: true, presence: true, email: true
validates :login, uniqueness: true, presence: true
Expand Down
4 changes: 4 additions & 0 deletions app/views/web/topics/_form.html.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
= f.input :state_event, as: :state_event
= f.input :name
= f.input :body
= f.submit
2 changes: 2 additions & 0 deletions app/views/web/topics/edit.html.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
= simple_form_for @topic do |f|
= render 'form', f: f
5 changes: 1 addition & 4 deletions app/views/web/topics/new.html.haml
Original file line number Diff line number Diff line change
@@ -1,5 +1,2 @@
= simple_form_for @topic do |f|
= f.input :state_event, as: :state_event
= f.input :name
= f.input :body
= f.submit
= render 'form', f: f
2 changes: 2 additions & 0 deletions app/views/web/users/comments/index.html.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
%h1 Web::Users::Comments#index
%p Find me in app/views/web/users/comments/index.html.haml
2 changes: 1 addition & 1 deletion app/views/web/users/index.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
%tbody
- @users.each do |u|
%tr
%td= link_to u, user_path(u)
%td= link_to u, user_path(u.login)
%td= u.human_state_name
%td= l u.created_at

Expand Down
2 changes: 0 additions & 2 deletions config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ class Application < Rails::Application
# Application configuration should go into files in config/initializers
# -- all .rb files in that directory are automatically loaded.

config.logger = Logger.new(STDOUT)

config.autoload_paths += Dir["#{config.root}/lib/**/"]
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
Expand Down
2 changes: 2 additions & 0 deletions config/environments/production.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
# Rake tasks automatically ignore this option for performance.
config.eager_load = true

config.logger = Logger.new(STDOUT)

# Full error reports are disabled and caching is turned on.
config.consider_all_requests_local = false
config.action_controller.perform_caching = true
Expand Down
1 change: 1 addition & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
end
scope module: :users do
resources :topics, only: [:index]
resources :comments, only: [:index]
end
end
resources :hubs, only: [:index]
Expand Down
15 changes: 15 additions & 0 deletions test/controllers/web/users/comments_controller_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
require 'test_helper'

class Web::Users::CommentsControllerTest < ActionController::TestCase
setup do
@user = create :user
@topic = create :topic, creator: @user
@params = {user_id: @user.login}
end

test "should get index" do
get :index, @params
assert_response :success
end

end
4 changes: 4 additions & 0 deletions test/helpers/web/users/comments_helper_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
require 'test_helper'

class Web::Users::CommentsHelperTest < ActionView::TestCase
end

0 comments on commit a80f0ae

Please sign in to comment.