Browse Source

Fix User being able to add bikes

topic-sass
Jason Denney 11 years ago
parent
commit
3e480981c7
  1. 2
      app/models/ability.rb
  2. 4
      app/views/site/index.html.haml

2
app/models/ability.rb

@ -23,7 +23,7 @@ class Ability
def user def user
can :read, :all can :read, :all
can :manage, Bike, :id => @current_user.bike_id unless @current_user.bike.nil? can :manage, @current_user.bike unless @current_user.bike.nil?
can :manage, ::ActsAsLoggable::Log, :loggable_type => "Bike", :loggable_id => @current_user.bike_id can :manage, ::ActsAsLoggable::Log, :loggable_type => "Bike", :loggable_id => @current_user.bike_id
can :manage, ::ActsAsLoggable::Log, :loggable_type => "User", :loggable_id => @current_user.id can :manage, ::ActsAsLoggable::Log, :loggable_type => "User", :loggable_id => @current_user.id
end end

4
app/views/site/index.html.haml

@ -6,6 +6,7 @@
%a{class: "btn btn-lg btn-block btn-primary", href: new_time_entry_path} Add Time Entry %a{class: "btn btn-lg btn-block btn-primary", href: new_time_entry_path} Add Time Entry
%p %p
%a{class: "btn btn-lg btn-block btn-primary", href: time_entries_path} View Timesheet %a{class: "btn btn-lg btn-block btn-primary", href: time_entries_path} View Timesheet
- if can? :manage, Bike
%p %p
%a{class: "btn btn-lg btn-block btn-primary", href: new_bike_path} Add Bike %a{class: "btn btn-lg btn-block btn-primary", href: new_bike_path} Add Bike
@ -13,9 +14,8 @@
%p %p
%a{class: "btn btn-lg btn-block btn-primary", href: bike_path(@bike)} View Your Bike %a{class: "btn btn-lg btn-block btn-primary", href: bike_path(@bike)} View Your Bike
%p %p
%p %p
%a{class: "btn btn-lg btn-block btn-primary hidden-xs", href: admin_index_path} Admin View %a{class: "btn btn-lg btn-block btn-primary hidden-xs", href: admin_index_path} Desktop View
%p %p
%input{id: "index_logout", value: "Logout", type: "button", class: "btn btn-lg btn-block btn-danger", "data-url" => destroy_user_session_path } %input{id: "index_logout", value: "Logout", type: "button", class: "btn btn-lg btn-block btn-danger", "data-url" => destroy_user_session_path }

Loading…
Cancel
Save