Skip to content

Commit 9a06105

Browse files
committed
Funcional
1 parent 142d405 commit 9a06105

File tree

28 files changed

+603
-0
lines changed

28 files changed

+603
-0
lines changed

Gemfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ git_source(:github) do |repo_name|
55
"https://github.com/#{repo_name}.git"
66
end
77

8+
gem 'carrierwave' #Upload da img
9+
gem 'mini_magick' #Para resize das imgs
810

911
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
1012
gem 'rails', '~> 5.1.4'

Gemfile.lock

Lines changed: 193 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,193 @@
1+
GEM
2+
remote: https://rubygems.org/
3+
specs:
4+
actioncable (5.1.4)
5+
actionpack (= 5.1.4)
6+
nio4r (~> 2.0)
7+
websocket-driver (~> 0.6.1)
8+
actionmailer (5.1.4)
9+
actionpack (= 5.1.4)
10+
actionview (= 5.1.4)
11+
activejob (= 5.1.4)
12+
mail (~> 2.5, >= 2.5.4)
13+
rails-dom-testing (~> 2.0)
14+
actionpack (5.1.4)
15+
actionview (= 5.1.4)
16+
activesupport (= 5.1.4)
17+
rack (~> 2.0)
18+
rack-test (>= 0.6.3)
19+
rails-dom-testing (~> 2.0)
20+
rails-html-sanitizer (~> 1.0, >= 1.0.2)
21+
actionview (5.1.4)
22+
activesupport (= 5.1.4)
23+
builder (~> 3.1)
24+
erubi (~> 1.4)
25+
rails-dom-testing (~> 2.0)
26+
rails-html-sanitizer (~> 1.0, >= 1.0.3)
27+
activejob (5.1.4)
28+
activesupport (= 5.1.4)
29+
globalid (>= 0.3.6)
30+
activemodel (5.1.4)
31+
activesupport (= 5.1.4)
32+
activerecord (5.1.4)
33+
activemodel (= 5.1.4)
34+
activesupport (= 5.1.4)
35+
arel (~> 8.0)
36+
activesupport (5.1.4)
37+
concurrent-ruby (~> 1.0, >= 1.0.2)
38+
i18n (~> 0.7)
39+
minitest (~> 5.1)
40+
tzinfo (~> 1.1)
41+
addressable (2.5.2)
42+
public_suffix (>= 2.0.2, < 4.0)
43+
arel (8.0.0)
44+
bindex (0.5.0)
45+
builder (3.2.3)
46+
byebug (9.1.0)
47+
capybara (2.17.0)
48+
addressable
49+
mini_mime (>= 0.1.3)
50+
nokogiri (>= 1.3.3)
51+
rack (>= 1.0.0)
52+
rack-test (>= 0.5.4)
53+
xpath (>= 2.0, < 4.0)
54+
carrierwave (1.2.2)
55+
activemodel (>= 4.0.0)
56+
activesupport (>= 4.0.0)
57+
mime-types (>= 1.16)
58+
childprocess (0.8.0)
59+
ffi (~> 1.0, >= 1.0.11)
60+
coffee-rails (4.2.2)
61+
coffee-script (>= 2.2.0)
62+
railties (>= 4.0.0)
63+
coffee-script (2.4.1)
64+
coffee-script-source
65+
execjs
66+
coffee-script-source (1.12.2)
67+
concurrent-ruby (1.0.5)
68+
crass (1.0.3)
69+
erubi (1.7.0)
70+
execjs (2.7.0)
71+
ffi (1.9.18)
72+
globalid (0.4.1)
73+
activesupport (>= 4.2.0)
74+
i18n (0.9.1)
75+
concurrent-ruby (~> 1.0)
76+
jbuilder (2.7.0)
77+
activesupport (>= 4.2.0)
78+
multi_json (>= 1.2)
79+
loofah (2.1.1)
80+
crass (~> 1.0.2)
81+
nokogiri (>= 1.5.9)
82+
mail (2.7.0)
83+
mini_mime (>= 0.1.1)
84+
method_source (0.9.0)
85+
mime-types (3.1)
86+
mime-types-data (~> 3.2015)
87+
mime-types-data (3.2016.0521)
88+
mini_magick (4.8.0)
89+
mini_mime (1.0.0)
90+
mini_portile2 (2.3.0)
91+
minitest (5.11.1)
92+
multi_json (1.12.2)
93+
nio4r (2.2.0)
94+
nokogiri (1.8.1)
95+
mini_portile2 (~> 2.3.0)
96+
public_suffix (3.0.1)
97+
puma (3.11.0)
98+
rack (2.0.3)
99+
rack-test (0.8.2)
100+
rack (>= 1.0, < 3)
101+
rails (5.1.4)
102+
actioncable (= 5.1.4)
103+
actionmailer (= 5.1.4)
104+
actionpack (= 5.1.4)
105+
actionview (= 5.1.4)
106+
activejob (= 5.1.4)
107+
activemodel (= 5.1.4)
108+
activerecord (= 5.1.4)
109+
activesupport (= 5.1.4)
110+
bundler (>= 1.3.0)
111+
railties (= 5.1.4)
112+
sprockets-rails (>= 2.0.0)
113+
rails-dom-testing (2.0.3)
114+
activesupport (>= 4.2.0)
115+
nokogiri (>= 1.6)
116+
rails-html-sanitizer (1.0.3)
117+
loofah (~> 2.0)
118+
railties (5.1.4)
119+
actionpack (= 5.1.4)
120+
activesupport (= 5.1.4)
121+
method_source
122+
rake (>= 0.8.7)
123+
thor (>= 0.18.1, < 2.0)
124+
rake (12.3.0)
125+
rb-fsevent (0.10.2)
126+
rb-inotify (0.9.10)
127+
ffi (>= 0.5.0, < 2)
128+
rubyzip (1.2.1)
129+
sass (3.5.5)
130+
sass-listen (~> 4.0.0)
131+
sass-listen (4.0.0)
132+
rb-fsevent (~> 0.9, >= 0.9.4)
133+
rb-inotify (~> 0.9, >= 0.9.7)
134+
sass-rails (5.0.7)
135+
railties (>= 4.0.0, < 6)
136+
sass (~> 3.1)
137+
sprockets (>= 2.8, < 4.0)
138+
sprockets-rails (>= 2.0, < 4.0)
139+
tilt (>= 1.1, < 3)
140+
selenium-webdriver (3.8.0)
141+
childprocess (~> 0.5)
142+
rubyzip (~> 1.0)
143+
sprockets (3.7.1)
144+
concurrent-ruby (~> 1.0)
145+
rack (> 1, < 3)
146+
sprockets-rails (3.2.1)
147+
actionpack (>= 4.0)
148+
activesupport (>= 4.0)
149+
sprockets (>= 3.0.0)
150+
sqlite3 (1.3.13)
151+
thor (0.20.0)
152+
thread_safe (0.3.6)
153+
tilt (2.0.8)
154+
turbolinks (5.0.1)
155+
turbolinks-source (~> 5)
156+
turbolinks-source (5.0.3)
157+
tzinfo (1.2.4)
158+
thread_safe (~> 0.1)
159+
uglifier (4.1.2)
160+
execjs (>= 0.3.0, < 3)
161+
web-console (3.5.1)
162+
actionview (>= 5.0)
163+
activemodel (>= 5.0)
164+
bindex (>= 0.4.0)
165+
railties (>= 5.0)
166+
websocket-driver (0.6.5)
167+
websocket-extensions (>= 0.1.0)
168+
websocket-extensions (0.1.3)
169+
xpath (3.0.0)
170+
nokogiri (~> 1.8)
171+
172+
PLATFORMS
173+
ruby
174+
175+
DEPENDENCIES
176+
byebug
177+
capybara (~> 2.13)
178+
carrierwave
179+
coffee-rails (~> 4.2)
180+
jbuilder (~> 2.5)
181+
mini_magick
182+
puma (~> 3.7)
183+
rails (~> 5.1.4)
184+
sass-rails (~> 5.0)
185+
selenium-webdriver
186+
sqlite3
187+
turbolinks (~> 5)
188+
tzinfo-data
189+
uglifier (>= 1.3.0)
190+
web-console (>= 3.3.0)
191+
192+
BUNDLED WITH
193+
1.16.0
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Place all the behaviors and hooks related to the matching controller here.
2+
# All this logic will automatically be available in application.js.
3+
# You can use CoffeeScript in this file: http://coffeescript.org/

app/assets/stylesheets/fotos.scss

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// Place all the styles related to the Fotos controller here.
2+
// They will automatically be included in application.css.
3+
// You can use Sass (SCSS) here: http://sass-lang.com/
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
body {
2+
background-color: #fff;
3+
color: #333;
4+
margin: 33px;
5+
font-family: verdana, arial, helvetica, sans-serif;
6+
font-size: 13px;
7+
line-height: 18px;
8+
}
9+
10+
p, ol, ul, td {
11+
font-family: verdana, arial, helvetica, sans-serif;
12+
font-size: 13px;
13+
line-height: 18px;
14+
}
15+
16+
pre {
17+
background-color: #eee;
18+
padding: 10px;
19+
font-size: 11px;
20+
}
21+
22+
a {
23+
color: #000;
24+
25+
&:visited {
26+
color: #666;
27+
}
28+
29+
&:hover {
30+
color: #fff;
31+
background-color: #000;
32+
}
33+
}
34+
35+
th {
36+
padding-bottom: 5px;
37+
}
38+
39+
td {
40+
padding: 0 5px 7px;
41+
}
42+
43+
div {
44+
&.field, &.actions {
45+
margin-bottom: 10px;
46+
}
47+
}
48+
49+
#notice {
50+
color: green;
51+
}
52+
53+
.field_with_errors {
54+
padding: 2px;
55+
background-color: red;
56+
display: table;
57+
}
58+
59+
#error_explanation {
60+
width: 450px;
61+
border: 2px solid red;
62+
padding: 7px 7px 0;
63+
margin-bottom: 20px;
64+
background-color: #f0f0f0;
65+
66+
h2 {
67+
text-align: left;
68+
font-weight: bold;
69+
padding: 5px 5px 5px 15px;
70+
font-size: 12px;
71+
margin: -7px -7px 0;
72+
background-color: #c00;
73+
color: #fff;
74+
}
75+
76+
ul li {
77+
font-size: 12px;
78+
list-style: square;
79+
}
80+
}
81+
82+
label {
83+
display: block;
84+
}
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
class FotosController < ApplicationController
2+
before_action :set_foto, only: [:show, :edit, :update, :destroy]
3+
4+
# GET /fotos
5+
# GET /fotos.json
6+
def index
7+
@fotos = Foto.all
8+
end
9+
10+
# GET /fotos/1
11+
# GET /fotos/1.json
12+
def show
13+
end
14+
15+
# GET /fotos/new
16+
def new
17+
@foto = Foto.new
18+
end
19+
20+
# GET /fotos/1/edit
21+
def edit
22+
end
23+
24+
# POST /fotos
25+
# POST /fotos.json
26+
def create
27+
@foto = Foto.new(foto_params)
28+
29+
respond_to do |format|
30+
if @foto.save
31+
format.html { redirect_to @foto, notice: 'Foto was successfully created.' }
32+
format.json { render :show, status: :created, location: @foto }
33+
else
34+
format.html { render :new }
35+
format.json { render json: @foto.errors, status: :unprocessable_entity }
36+
end
37+
end
38+
end
39+
40+
# PATCH/PUT /fotos/1
41+
# PATCH/PUT /fotos/1.json
42+
def update
43+
respond_to do |format|
44+
if @foto.update(foto_params)
45+
format.html { redirect_to @foto, notice: 'Foto was successfully updated.' }
46+
format.json { render :show, status: :ok, location: @foto }
47+
else
48+
format.html { render :edit }
49+
format.json { render json: @foto.errors, status: :unprocessable_entity }
50+
end
51+
end
52+
end
53+
54+
# DELETE /fotos/1
55+
# DELETE /fotos/1.json
56+
def destroy
57+
@foto.destroy
58+
respond_to do |format|
59+
format.html { redirect_to fotos_url, notice: 'Foto was successfully destroyed.' }
60+
format.json { head :no_content }
61+
end
62+
end
63+
64+
private
65+
# Use callbacks to share common setup or constraints between actions.
66+
def set_foto
67+
@foto = Foto.find(params[:id])
68+
end
69+
70+
# Never trust parameters from the scary internet, only allow the white list through.
71+
def foto_params
72+
params.require(:foto).permit(:nome, :img)
73+
end
74+
end

app/helpers/fotos_helper.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
module FotosHelper
2+
end

app/models/foto.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
class Foto < ApplicationRecord
2+
mount_uploader :img, ImageUploader
3+
end

0 commit comments

Comments
 (0)