Last active
August 29, 2015 14:05
-
-
Save px-amaac/76f391075cdd4a677471 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<p> | |
<%= form_for([@photo, @tag]) do |f| %> | |
<div class="field"> | |
<%= f.label :key %> | |
<%= f.text_field :key %> | |
</div> | |
<div class="field"> | |
<%= f.label :value %> | |
<%= f.text_field :value %> | |
</div> | |
<%= f.submit "Tag Photo", class: "button success" %> | |
<% end %> | |
</p> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class HomeController < ApplicationController | |
def index | |
@user = current_user | |
@photos = Photo.all | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<h1>All Photos</h1> | |
<div class="row"> | |
<% @photos.each do |photo| %> | |
<div class "row"> | |
<h2> <%= photo.title %> </h2> | |
<% if user_signed_in? && photo.user_id == current_user.id %> | |
<%= link_to image_tag(photo.image.url(:thumb)), photo_path(photo) %> | |
////////////////////I need the form here????????????????????????????????????? | |
<%= link_to 'Destroy', photo, method: :delete, data: { confirm: 'Are you sure?' }, :class => "button alert" %> | |
<% else %> | |
<%= image_tag(photo.image.url(:thumb)) %> | |
<% end %> | |
</div> | |
<% end %> | |
</div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Rails.application.routes.draw do | |
get "tag/create" | |
get 'home/index' | |
root :to => 'home#index' | |
resources :photos do | |
resources :tags, only: [:create, :destroy] | |
end | |
devise_for :users |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment