Let use choose his dagschotel

This commit is contained in:
Benjamin Cousaert 2014-12-10 14:18:56 +01:00
parent cfd7f6fc0f
commit bbc8901353
4 changed files with 26 additions and 2 deletions

View file

@ -15,8 +15,13 @@ class ApplicationController < ActionController::Base
protected protected
def configure_permitted_parameters def configure_permitted_parameters
devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(:nickname, :name, :last_name, :password, :password_confirmation, :current_password, :avatar) } devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(
devise_parameter_sanitizer.for(:account_update) { |u| u.permit(:password, :password_confirmation, :current_password, :avatar) } :nickname, :name, :last_name, :password, :password_confirmation,
:current_password, :avatar
) }
devise_parameter_sanitizer.for(:account_update) { |u| u.permit(
:password, :password_confirmation, :current_password, :avatar
) }
end end
end end

View file

@ -14,4 +14,10 @@ class UsersController < ApplicationController
redirect_to users_path redirect_to users_path
end end
def dagschotel
user = User.find(params[:user_id])
user.dagschotel = Product.find(params[:product_id])
user.save
redirect_to edit_user_registration_path(user)
end
end end

View file

@ -17,3 +17,15 @@
<%= f.submit "Update", class: 'btn btn-primary' %> <%= f.submit "Update", class: 'btn btn-primary' %>
<% end %> <% end %>
<% if current_user.dagschotel.present? %>
<h3>Current Dagschotel:</h3>
<div>
<%= image_tag current_user.dagschotel.avatar %>
</div>
<% end %>
<h4>Choose new Dagschotel:</h4>
<% Product.all.each do |p| %>
<%= link_to image_tag(p.avatar), user_dagschotel_path(current_user, p) %>
<% end %>

View file

@ -8,6 +8,7 @@ Rails.application.routes.draw do
resources :orders, only: [:new, :create, :index] do resources :orders, only: [:new, :create, :index] do
end end
get 'quickpay' => 'orders#quickpay' get 'quickpay' => 'orders#quickpay'
get 'dagschotel/:product_id' => 'users#dagschotel', as: "dagschotel"
end end
resources :products resources :products