diff --git a/app/assets/images/dollar.png b/app/assets/images/dollar.png new file mode 100644 index 0000000000..e4df25001f Binary files /dev/null and b/app/assets/images/dollar.png differ diff --git a/app/assets/stylesheets/habits.css.scss b/app/assets/stylesheets/habits.css.scss index 26bb04787b..e30a80baa2 100644 --- a/app/assets/stylesheets/habits.css.scss +++ b/app/assets/stylesheets/habits.css.scss @@ -21,7 +21,7 @@ margin-left:0px; } -.habit { +.habit, .reward { list-style:none; -moz-border-radius: 3px; -webkit-border-radius: 3px; @@ -32,7 +32,7 @@ text-shadow:none; } -.habit:hover { +.habit:hover, .reward:hover { cursor: move; } diff --git a/app/controllers/habits_controller.rb b/app/controllers/habits_controller.rb index 05daba8648..1c23a8ba2e 100644 --- a/app/controllers/habits_controller.rb +++ b/app/controllers/habits_controller.rb @@ -8,6 +8,7 @@ class HabitsController < ApplicationController @habits = current_user.habits.where(:habit_type => Habit::ALWAYS) @daily = current_user.habits.where(:habit_type => Habit::DAILY) @one_time = current_user.habits.where(:habit_type => Habit::ONE_TIME).where(:done=>false) + @rewards = current_user.rewards respond_to do |format| format.html # index.html.erb diff --git a/app/controllers/rewards_controller.rb b/app/controllers/rewards_controller.rb index 1a30f9064a..a655408846 100644 --- a/app/controllers/rewards_controller.rb +++ b/app/controllers/rewards_controller.rb @@ -1,30 +1,10 @@ class RewardsController < ApplicationController - # GET /rewards - # GET /rewards.json - def index - @rewards = Reward.all - - respond_to do |format| - format.html # index.html.erb - format.json { render json: @rewards } - end - end - - # GET /rewards/1 - # GET /rewards/1.json - def show - @reward = Reward.find(params[:id]) - - respond_to do |format| - format.html # show.html.erb - format.json { render json: @reward } - end - end # GET /rewards/new # GET /rewards/new.json def new @reward = Reward.new + @reward.user_id = current_user.id respond_to do |format| format.html # new.html.erb @@ -34,17 +14,18 @@ class RewardsController < ApplicationController # GET /rewards/1/edit def edit - @reward = Reward.find(params[:id]) + @reward.user_id = current_user.id end # POST /rewards # POST /rewards.json def create @reward = Reward.new(params[:reward]) + @reward.user_id = current_user.id respond_to do |format| if @reward.save - format.html { redirect_to @reward, notice: 'Reward was successfully created.' } + format.html { redirect_to habits_url, notice: 'Reward was successfully created.' } format.json { render json: @reward, status: :created, location: @reward } else format.html { render action: "new" } @@ -56,11 +37,11 @@ class RewardsController < ApplicationController # PUT /rewards/1 # PUT /rewards/1.json def update - @reward = Reward.find(params[:id]) + @reward = curren_user.rewards.find(params[:id]) respond_to do |format| if @reward.update_attributes(params[:reward]) - format.html { redirect_to @reward, notice: 'Reward was successfully updated.' } + format.html { redirect_to habits_url, notice: 'Reward was successfully updated.' } format.json { head :no_content } else format.html { render action: "edit" } @@ -72,11 +53,11 @@ class RewardsController < ApplicationController # DELETE /rewards/1 # DELETE /rewards/1.json def destroy - @reward = Reward.find(params[:id]) + @reward = current_user.reward.find(params[:id]) @reward.destroy respond_to do |format| - format.html { redirect_to rewards_url } + format.html { redirect_to habits_url } format.json { head :no_content } end end diff --git a/app/views/habits/index.html.erb b/app/views/habits/index.html.erb index ae675e63c1..f896a354a3 100644 --- a/app/views/habits/index.html.erb +++ b/app/views/habits/index.html.erb @@ -55,9 +55,19 @@ <%= render 'money'%>
| Name | -Value | -Position | -User | -- | - | - |
|---|---|---|---|---|---|---|
| <%= reward.name %> | -<%= reward.value %> | -<%= reward.position %> | -<%= reward.user_id %> | -<%= link_to 'Show', reward %> | -<%= link_to 'Edit', edit_reward_path(reward) %> | -<%= link_to 'Destroy', reward, confirm: 'Are you sure?', method: :delete %> | -
<%= notice %>
- -- Name: - <%= @reward.name %> -
- -- Value: - <%= @reward.value %> -
- -- Position: - <%= @reward.position %> -
- -- User: - <%= @reward.user_id %> -
- - -<%= link_to 'Edit', edit_reward_path(@reward) %> | -<%= link_to 'Back', rewards_path %>