Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 6 additions & 10 deletions app/controllers/artists_controller.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
class ArtistsController < ApplicationController

def index
@Artists = Artist.all
@artists = Artist.all
end

def show
@Artist = Artist.find(params[:id])
@artist = Artist.find(params[:id])
@songs = @artist.songs
@photos = @artist.photo

end

def new
Expand All @@ -18,9 +18,7 @@ def create
@artist = @artists.build
if @artist.save
redirect_to @artist
image_params.each do |image|
@artist.photo.create(image: image)
end

else
render 'new'
end
Expand All @@ -38,9 +36,7 @@ def update

if @artist.update(artist_params)
redirect_to @artist
image_params.each do |image|
@artist.photo.create(image: image)
end

else
render 'edit'
end
Expand All @@ -54,7 +50,7 @@ def artist_params
params
.require(:artist)
.permit(
:name, :picture, :nationality, :birthyear
:name, :picture, :nationality, :birthyear, :image
)
end
def image_params
Expand Down
4 changes: 2 additions & 2 deletions app/views/artists/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@
<%@artists.each do |artist| %>
<div class="col-md-3 right">
<%= link_to artist.name, artist_path(artist.id), class: "btn btn-default" %>
<% @artist.image %>

<div class="panel panel-default">
<div class="panel-heading">
<%= image_tag artist.image.thumbnail %>
</div>
</div>
<% end %>




Expand Down
5 changes: 5 additions & 0 deletions db/migrate/20171111200504_add_image_to_artists.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class AddImageToArtists < ActiveRecord::Migration[5.1]
def change
add_column :artists, :image, :string
end
end
7 changes: 6 additions & 1 deletion db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 20171111174746) do

ActiveRecord::Schema.define(version: 20171111200504) do
=======



# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
Expand All @@ -23,6 +27,7 @@
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.bigint "artist_id"
t.string "image"
t.index ["artist_id"], name: "index_artists_on_artist_id"
end

Expand Down
4 changes: 0 additions & 4 deletions db/seeds.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,3 @@
{name: "All We Know", duration: 4.01 , release: d3, album: "Monologue of thousand voices" ,label: "Melodiya", artist: artist2 },
{name: "Udi baba", duration: 6.19 ,release: d4, album: "Vidhata",label: "", artist: artist3 } ])

# Photos
#photo1 = Photo.create!(remote_image_url: "http://res.cloudinary.com/djhc9jhiq/image/upload/v1510419645/Heilu_mergia_aps8r3.jpg", artist: artist1)
#photo2 = Photo.create!(remote_image_url: "http://res.cloudinary.com/djhc9jhiq/image/upload/v1510419626/alexanderkatenin_rsb1zv.jpg", artist: artist2)
#photo3 = Photo.create!(remote_image_url: "http://res.cloudinary.com/djhc9jhiq/image/upload/v1510419618/Ashla_ud6bjd.jpg", artist: artist3)