From a7c6e22e01866acf2ba8b3c38d648b0dad94392f Mon Sep 17 00:00:00 2001 From: Daniel Vincent Grippi <Dan@SPEEDRACER.local> Date: Tue, 14 Sep 2010 09:44:09 -0700 Subject: [PATCH] DG RS; passing around params[:aspect]. querying in application controller for current aspect. --- app/controllers/application_controller.rb | 7 ++++++- app/helpers/application_helper.rb | 4 ++-- app/views/albums/_album.html.haml | 7 +++---- app/views/albums/index.html.haml | 2 +- app/views/albums/show.html.haml | 2 +- 5 files changed, 13 insertions(+), 9 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 7d7c28dd24..d747a219cb 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -36,7 +36,12 @@ class ApplicationController < ActionController::Base def set_friends_and_status if current_user - @aspect = :all + if params[:aspect] == 'all' || params[:aspect] == nil + @aspect = :all + else + @aspect = current_user.aspect_by_id( params[:aspect]) + end + @aspects = current_user.aspects @friends = current_user.friends end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 04ae66897c..234cf80ee3 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -23,8 +23,8 @@ module ApplicationHelper @aspect != :all && @aspect.id == aspect.id end - def object_path(object) - eval("#{object.class.to_s.underscore}_path(object)") + def object_path(object, opts = {}) + eval("#{object.class.to_s.underscore}_path(object, opts)") end def object_fields(object) diff --git a/app/views/albums/_album.html.haml b/app/views/albums/_album.html.haml index 3ff1a507d1..9e0585781c 100644 --- a/app/views/albums/_album.html.haml +++ b/app/views/albums/_album.html.haml @@ -17,17 +17,16 @@ -# .album{:id => post.id, :class => ("mine" if current_user.owns?(post))} - %div.name - = link_to post.name, object_path(post) + = link_to post.name, object_path(post, :aspect => params[:aspect]) %div.time by = link_to ((current_user.person == post.person)? 'you' : post.person.real_name), person_path(post.person) %br - = link_to(how_long_ago(post), object_path(post)) + = link_to(how_long_ago(post), object_path(post, :aspect => params[:aspect])) %div.image_cycle - for photo in post.photos[0..3] - = link_to (image_tag photo.url(:thumb_large)), album_path(post) + = link_to (image_tag photo.url(:thumb_large)), album_path(post, :aspect => params[:aspect]) diff --git a/app/views/albums/index.html.haml b/app/views/albums/index.html.haml index 114eef205d..3f54c05eea 100644 --- a/app/views/albums/index.html.haml +++ b/app/views/albums/index.html.haml @@ -24,7 +24,7 @@ }); = content_for :page_title do - = link_to "â—‚ Home", aspects_path + = link_to "â—‚ Home", aspects_path, :aspect => params[:aspect] - content_for :left_pane do = render "shared/aspect_friends" diff --git a/app/views/albums/show.html.haml b/app/views/albums/show.html.haml index 10a239c64c..e55d1962ba 100644 --- a/app/views/albums/show.html.haml +++ b/app/views/albums/show.html.haml @@ -25,7 +25,7 @@ }); = content_for :page_title do - = link_to "â—‚ Albums", albums_path + = link_to "â—‚ Albums", albums_path(:aspect => @aspect) - content_for :left_pane do = render "shared/aspect_friends" -- GitLab