<%= biz_plan.name %> by <%= biz_plan.user.username %>
+<%= biz_plan.name %>
by<%= biz_plan.user.username %>
<% if biz_plan.user == current_user %> - + - + <% end %>diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 131aede..4bb2a0a 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -12,7 +12,11 @@ class ApplicationController < Sinatra::Base end get "/" do - erb :welcome + if logged_in? + redirect '/bix_plans' + else + erb :welcome + end end helpers do @@ -20,12 +24,12 @@ class ApplicationController < Sinatra::Base def logged_in? !!current_user end - + def current_user @current_user ||= User.find_by_id(session[:user_id]) if session[:user_id] # uses memoization to prevent duplicate database queries end - + end -end \ No newline at end of file +end diff --git a/app/views/biz_plans/index.erb b/app/views/biz_plans/index.erb index 43c9a3f..ed19398 100644 --- a/app/views/biz_plans/index.erb +++ b/app/views/biz_plans/index.erb @@ -2,16 +2,16 @@ <% @biz_plans.each do |biz_plan| %>
<%= biz_plan.name %> by <%= biz_plan.user.username %>
+<%= biz_plan.user.username %>
<% if biz_plan.user == current_user %> - + - + <% end %>