Commit cb04c29f by nnnghia98

using gem draper

parent 23c11742
......@@ -26,6 +26,7 @@ gem 'sunspot_solr'
gem 'devise'
gem 'activerecord-import'
gem 'config'
gem 'draper'
# Use Redis adapter to run Action Cable in production
# gem 'redis', '~> 4.0'
# Use Active Model has_secure_password
......
......@@ -42,6 +42,10 @@ GEM
globalid (>= 0.3.6)
activemodel (6.0.1)
activesupport (= 6.0.1)
activemodel-serializers-xml (1.0.2)
activemodel (> 5.x)
activesupport (> 5.x)
builder (~> 3.1)
activerecord (6.0.1)
activemodel (= 6.0.1)
activesupport (= 6.0.1)
......@@ -99,6 +103,12 @@ GEM
railties (>= 4.1.0)
responders
warden (~> 1.2.3)
draper (3.1.0)
actionpack (>= 5.0)
activemodel (>= 5.0)
activemodel-serializers-xml (>= 1.0)
activesupport (>= 5.0)
request_store (>= 1.0)
dry-configurable (0.9.0)
concurrent-ruby (~> 1.0)
dry-core (~> 0.4, >= 0.4.7)
......@@ -224,6 +234,8 @@ GEM
rb-inotify (0.10.0)
ffi (~> 1.0)
regexp_parser (1.6.0)
request_store (1.4.1)
rack (>= 1.4)
responders (3.0.0)
actionpack (>= 5.0)
railties (>= 5.0)
......@@ -308,6 +320,7 @@ DEPENDENCIES
carrierwave
config
devise
draper
jbuilder
jquery-rails (= 4.3.1)
kaminari
......
class JobDecorator < Draper::Decorator
delegate_all
decorates_association :city
def city_name
object&.cities&.first&.name
end
def display_short_des
object.short_des.truncate(250)
end
end
......@@ -6,7 +6,7 @@
</dl>
<dl class="job_data_row">
<dt>Short description</dt>
<dd><%= truncate(job.short_des, length: 250) %></dd>
<dd><%= job.decorate.display_short_des %></dd>
</dl>
<dl class="job_data_row">
<dt>Salary</dt>
......@@ -14,7 +14,7 @@
</dl>
<dl class="job_data_row">
<dt>Location</dt>
<dd><%= job&.cities&.first&.name %></dd>
<dd><%= job.decorate.city_name %></dd>
</dl>
</div>
<button type="button" class="btn btn-outline-secondary">Favorite</button>
......
......@@ -6,7 +6,7 @@
</dl>
<dl class="job_data_row">
<dt>Short description</dt>
<dd><%= truncate(latest_job.short_des, length: 250) %></dd>
<dd><%= latest_job.decorate.display_short_des %></dd>
</dl>
<dl class="job_data_row">
<dt>Salary</dt>
......@@ -14,7 +14,7 @@
</dl>
<dl class="job_data_row">
<dt>Location</dt>
<dd><%= latest_job&.cities&.first&.name %></dd>
<dd><%= latest_job.decorate.city_name %></dd>
</dl>
</div>
</div>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment