MS IZ added an add to aspect form on the request partial

This commit is contained in:
ilya 2010-10-20 15:30:30 -07:00
parent 0afe83b5e3
commit 62700387ad
3 changed files with 13 additions and 4 deletions

View file

@ -46,6 +46,7 @@ class AspectsController < ApplicationController
def show
@aspect = current_user.aspect_by_id params[:id]
@friends_dropdown_array = current_user.friends.all(:person_id.nin => @aspect.person_ids )
unless @aspect
render :file => "#{Rails.root}/public/404.html", :layout => false, :status => 404
else
@ -92,13 +93,13 @@ class AspectsController < ApplicationController
end
def add_to_aspect
if current_user.add_person_to_aspect( params[:friend_id], params[:to_aspect_id])
if current_user.add_person_to_aspect( params[:friend_id], params[:aspect_id])
flash[:notice] = I18n.t 'aspects.add_to_aspect.success'
render :nothing => true
else
flash[:notice] = I18n.t 'aspects.add_to_aspect.success'
render :nothing => true, :status => 500
end
redirect_to aspects_path(params[:aspect_id])
end
private

View file

@ -8,6 +8,14 @@
=t('.add_a_new_friend_to')
%i= aspect.name
= form_tag '/aspects/add_to_aspect', :id => 'add_to_aspect' do
= select_tag :friend_id, options_from_collection_for_select(@friends_dropdown_array, "id", "real_name"), :include_blank => true
= hidden_field_tag :aspect_id, aspect.id
= submit_tag "add to #{@aspect.name}"
= form_for Request.new do |fr_request|
= fr_request.error_messages

View file

@ -76,7 +76,7 @@ describe AspectsController do
it 'adds the users to the aspect' do
@aspect1.reload
@aspect1.people.include?(@user2.person).should be false
post 'add_to_aspect', {'friend_id' => @user2.person.id, 'to_aspect_id' => @aspect1.id }
post 'add_to_aspect', {:friend_id => @user2.person.id, :aspect_id => @aspect1.id }
@aspect1.reload
@aspect1.people.include?(@user2.person).should be true
end