epom_rails 0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (77) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.rdoc +3 -0
  4. data/Rakefile +34 -0
  5. data/lib/epom_rails/acts_as.rb +63 -0
  6. data/lib/epom_rails/version.rb +3 -0
  7. data/lib/epom_rails.rb +14 -0
  8. data/lib/tasks/epom_rails_tasks.rake +4 -0
  9. data/test/dummy/README.rdoc +28 -0
  10. data/test/dummy/Rakefile +6 -0
  11. data/test/dummy/app/assets/javascripts/advertisers.js +2 -0
  12. data/test/dummy/app/assets/javascripts/application.js +13 -0
  13. data/test/dummy/app/assets/javascripts/campaigns.js +2 -0
  14. data/test/dummy/app/assets/stylesheets/advertisers.css +4 -0
  15. data/test/dummy/app/assets/stylesheets/application.css +15 -0
  16. data/test/dummy/app/assets/stylesheets/campaigns.css +4 -0
  17. data/test/dummy/app/assets/stylesheets/scaffold.css +56 -0
  18. data/test/dummy/app/controllers/advertisers_controller.rb +58 -0
  19. data/test/dummy/app/controllers/application_controller.rb +5 -0
  20. data/test/dummy/app/controllers/campaigns_controller.rb +58 -0
  21. data/test/dummy/app/helpers/advertisers_helper.rb +2 -0
  22. data/test/dummy/app/helpers/application_helper.rb +2 -0
  23. data/test/dummy/app/helpers/campaigns_helper.rb +2 -0
  24. data/test/dummy/app/models/advertiser.rb +3 -0
  25. data/test/dummy/app/models/campaign.rb +3 -0
  26. data/test/dummy/app/views/advertisers/_form.html.erb +37 -0
  27. data/test/dummy/app/views/advertisers/edit.html.erb +6 -0
  28. data/test/dummy/app/views/advertisers/index.html.erb +35 -0
  29. data/test/dummy/app/views/advertisers/new.html.erb +5 -0
  30. data/test/dummy/app/views/advertisers/show.html.erb +29 -0
  31. data/test/dummy/app/views/campaigns/_form.html.erb +33 -0
  32. data/test/dummy/app/views/campaigns/edit.html.erb +6 -0
  33. data/test/dummy/app/views/campaigns/index.html.erb +33 -0
  34. data/test/dummy/app/views/campaigns/new.html.erb +5 -0
  35. data/test/dummy/app/views/campaigns/show.html.erb +24 -0
  36. data/test/dummy/app/views/layouts/application.html.erb +14 -0
  37. data/test/dummy/bin/bundle +3 -0
  38. data/test/dummy/bin/rails +4 -0
  39. data/test/dummy/bin/rake +4 -0
  40. data/test/dummy/bin/setup +29 -0
  41. data/test/dummy/config/application.rb +26 -0
  42. data/test/dummy/config/boot.rb +5 -0
  43. data/test/dummy/config/database.yml +25 -0
  44. data/test/dummy/config/environment.rb +5 -0
  45. data/test/dummy/config/environments/development.rb +41 -0
  46. data/test/dummy/config/environments/production.rb +79 -0
  47. data/test/dummy/config/environments/test.rb +42 -0
  48. data/test/dummy/config/initializers/assets.rb +11 -0
  49. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  50. data/test/dummy/config/initializers/cookies_serializer.rb +3 -0
  51. data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  52. data/test/dummy/config/initializers/inflections.rb +16 -0
  53. data/test/dummy/config/initializers/mime_types.rb +4 -0
  54. data/test/dummy/config/initializers/session_store.rb +3 -0
  55. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  56. data/test/dummy/config/locales/en.yml +23 -0
  57. data/test/dummy/config/routes.rb +61 -0
  58. data/test/dummy/config/secrets.yml +22 -0
  59. data/test/dummy/config.ru +4 -0
  60. data/test/dummy/db/migrate/20150603151041_create_advertisers.rb +12 -0
  61. data/test/dummy/db/migrate/20150604125603_add_epom_id_to_advertiser.rb +5 -0
  62. data/test/dummy/db/migrate/20150608194916_create_campaigns.rb +12 -0
  63. data/test/dummy/db/schema.rb +36 -0
  64. data/test/dummy/public/404.html +67 -0
  65. data/test/dummy/public/422.html +67 -0
  66. data/test/dummy/public/500.html +66 -0
  67. data/test/dummy/public/favicon.ico +0 -0
  68. data/test/dummy/test/controllers/advertisers_controller_test.rb +49 -0
  69. data/test/dummy/test/controllers/campaigns_controller_test.rb +49 -0
  70. data/test/dummy/test/fixtures/advertisers.yml +13 -0
  71. data/test/dummy/test/fixtures/campaigns.yml +13 -0
  72. data/test/dummy/test/models/advertiser_test.rb +7 -0
  73. data/test/dummy/test/models/campaign_test.rb +7 -0
  74. data/test/epom_rails/acts_as_advertiser_test.rb +65 -0
  75. data/test/epom_rails_test.rb +7 -0
  76. data/test/test_helper.rb +27 -0
  77. metadata +229 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 627cf566abe1147d469cc965d59db47ec23a7c07
4
+ data.tar.gz: 59e1b683d0dd2bf4e699c574b44133fcb5c4810f
5
+ SHA512:
6
+ metadata.gz: 30257344d059d2583643eb191254a490448086623891bcf3cfdb36da9b67f93a7e059b73f4fb11a2e3c3eded13aa8a51cd5fc8422b2249f35739844af8c4bf58
7
+ data.tar.gz: 361e0454d81063855d57b0411898414ba6424048bb89d6d8e5018b77f3f793f0f0f5a374883a9357a5ed179d638a68bfddef7593812ec8bc66bf8f7904a5361b
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2015 Adrian Chang
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,3 @@
1
+ = EpomRails
2
+
3
+ This project rocks and uses MIT-LICENSE.
data/Rakefile ADDED
@@ -0,0 +1,34 @@
1
+ begin
2
+ require 'bundler/setup'
3
+ rescue LoadError
4
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
+ end
6
+
7
+ require 'rdoc/task'
8
+
9
+ RDoc::Task.new(:rdoc) do |rdoc|
10
+ rdoc.rdoc_dir = 'rdoc'
11
+ rdoc.title = 'EpomRails'
12
+ rdoc.options << '--line-numbers'
13
+ rdoc.rdoc_files.include('README.rdoc')
14
+ rdoc.rdoc_files.include('lib/**/*.rb')
15
+ end
16
+
17
+
18
+
19
+
20
+
21
+
22
+ Bundler::GemHelper.install_tasks
23
+
24
+ require 'rake/testtask'
25
+
26
+ Rake::TestTask.new(:test) do |t|
27
+ t.libs << 'lib'
28
+ t.libs << 'test'
29
+ t.pattern = 'test/**/*_test.rb'
30
+ t.verbose = false
31
+ end
32
+
33
+
34
+ task default: :test
@@ -0,0 +1,63 @@
1
+ class ActiveRecord::Base
2
+
3
+ def self.acts_as_advertiser(fields = {})
4
+ acts_as(Epom::Advertiser, fields)
5
+ end
6
+
7
+ def self.acts_as_campaign(fields = {})
8
+ acts_as(Epom::Campaign, fields)
9
+ end
10
+
11
+ private
12
+
13
+ def self.acts_as(klass, fields = {})
14
+ extend EpomRails
15
+
16
+ self.epom_klass = klass
17
+ self.epom_fields = fields
18
+
19
+ define_before_save
20
+ define_before_destroy
21
+ end
22
+
23
+ def self.define_before_save
24
+ klass = self.epom_klass
25
+ fields = self.epom_fields
26
+ before_save do
27
+ klass_name = klass.name.include?('::') ? klass.name.split('::').last : klass.name
28
+
29
+ timestamp = Time.now.to_i * 1000
30
+ body_params = {
31
+ :hash => Epom.create_hash(Epom.create_hash(ENV['password']), timestamp),
32
+ :timestamp => timestamp,
33
+ :username => ENV['username']
34
+ }
35
+ fields.each { |local_field, remote_field| body_params[remote_field] = self.send local_field }
36
+
37
+ if self.send fields.key('id')
38
+ # update in Epom
39
+ epom_response = klass.send "update_#{klass_name.downcase}", {}, body_params
40
+ else
41
+ # create in Epom
42
+ body_params.delete('id')
43
+ epom_response = klass.send "create_#{klass_name.downcase}", {}, body_params
44
+ # save id value returned from Epom in an Advertiser column
45
+ self.send "#{fields.key('id')}=", epom_response['id']
46
+ end
47
+ epom_response['success']
48
+ end
49
+ end
50
+
51
+ def self.define_before_destroy
52
+ klass = self.epom_klass
53
+ fields = self.epom_fields
54
+ before_destroy do
55
+ if self.send fields.key('id')
56
+ klass_name = klass.name.include?('::') ? klass.name.split('::').last : klass.name
57
+ epom_response = klass.send "delete_#{klass_name.downcase}", {"#{klass_name.downcase}Id" => self.send(fields.key('id'))}, {}
58
+ epom_response['success']
59
+ end
60
+ end
61
+ end
62
+
63
+ end
@@ -0,0 +1,3 @@
1
+ module EpomRails
2
+ VERSION = "0.2"
3
+ end
data/lib/epom_rails.rb ADDED
@@ -0,0 +1,14 @@
1
+ require 'epom'
2
+ require 'epom_rails/acts_as'
3
+
4
+ module EpomRails
5
+ attr_accessor :epom_klass, :epom_fields
6
+
7
+ def method_missing(method_name, *args)
8
+ if epom_klass.respond_to?(method_name)
9
+ epom_klass.send(method_name, args[0], args[1])
10
+ else
11
+ super
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :epom_rails do
3
+ # # Task goes here
4
+ # end
@@ -0,0 +1,28 @@
1
+ == README
2
+
3
+ This README would normally document whatever steps are necessary to get the
4
+ application up and running.
5
+
6
+ Things you may want to cover:
7
+
8
+ * Ruby version
9
+
10
+ * System dependencies
11
+
12
+ * Configuration
13
+
14
+ * Database creation
15
+
16
+ * Database initialization
17
+
18
+ * How to run the test suite
19
+
20
+ * Services (job queues, cache servers, search engines, etc.)
21
+
22
+ * Deployment instructions
23
+
24
+ * ...
25
+
26
+
27
+ Please feel free to use a different markup language if you do not plan to run
28
+ <tt>rake doc:app</tt>.
@@ -0,0 +1,6 @@
1
+ # Add your own tasks in files placed in lib/tasks ending in .rake,
2
+ # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3
+
4
+ require File.expand_path('../config/application', __FILE__)
5
+
6
+ Rails.application.load_tasks
@@ -0,0 +1,2 @@
1
+ // Place all the behaviors and hooks related to the matching controller here.
2
+ // All this logic will automatically be available in application.js.
@@ -0,0 +1,13 @@
1
+ // This is a manifest file that'll be compiled into application.js, which will include all the files
2
+ // listed below.
3
+ //
4
+ // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5
+ // or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
6
+ //
7
+ // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8
+ // compiled file.
9
+ //
10
+ // Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
11
+ // about supported directives.
12
+ //
13
+ //= require_tree .
@@ -0,0 +1,2 @@
1
+ // Place all the behaviors and hooks related to the matching controller here.
2
+ // All this logic will automatically be available in application.js.
@@ -0,0 +1,4 @@
1
+ /*
2
+ Place all the styles related to the matching controller here.
3
+ They will automatically be included in application.css.
4
+ */
@@ -0,0 +1,15 @@
1
+ /*
2
+ * This is a manifest file that'll be compiled into application.css, which will include all the files
3
+ * listed below.
4
+ *
5
+ * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
+ * or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
7
+ *
8
+ * You're free to add application-wide styles to this file and they'll appear at the bottom of the
9
+ * compiled file so the styles you add here take precedence over styles defined in any styles
10
+ * defined in the other CSS/SCSS files in this directory. It is generally better to create a new
11
+ * file per style scope.
12
+ *
13
+ *= require_tree .
14
+ *= require_self
15
+ */
@@ -0,0 +1,4 @@
1
+ /*
2
+ Place all the styles related to the matching controller here.
3
+ They will automatically be included in application.css.
4
+ */
@@ -0,0 +1,56 @@
1
+ body { background-color: #fff; color: #333; }
2
+
3
+ body, p, ol, ul, td {
4
+ font-family: verdana, arial, helvetica, sans-serif;
5
+ font-size: 13px;
6
+ line-height: 18px;
7
+ }
8
+
9
+ pre {
10
+ background-color: #eee;
11
+ padding: 10px;
12
+ font-size: 11px;
13
+ }
14
+
15
+ a { color: #000; }
16
+ a:visited { color: #666; }
17
+ a:hover { color: #fff; background-color:#000; }
18
+
19
+ div.field, div.actions {
20
+ margin-bottom: 10px;
21
+ }
22
+
23
+ #notice {
24
+ color: green;
25
+ }
26
+
27
+ .field_with_errors {
28
+ padding: 2px;
29
+ background-color: red;
30
+ display: table;
31
+ }
32
+
33
+ #error_explanation {
34
+ width: 450px;
35
+ border: 2px solid red;
36
+ padding: 7px;
37
+ padding-bottom: 0;
38
+ margin-bottom: 20px;
39
+ background-color: #f0f0f0;
40
+ }
41
+
42
+ #error_explanation h2 {
43
+ text-align: left;
44
+ font-weight: bold;
45
+ padding: 5px 5px 5px 15px;
46
+ font-size: 12px;
47
+ margin: -7px;
48
+ margin-bottom: 0px;
49
+ background-color: #c00;
50
+ color: #fff;
51
+ }
52
+
53
+ #error_explanation ul li {
54
+ font-size: 12px;
55
+ list-style: square;
56
+ }
@@ -0,0 +1,58 @@
1
+ class AdvertisersController < ApplicationController
2
+ before_action :set_advertiser, only: [:show, :edit, :update, :destroy]
3
+
4
+ # GET /advertisers
5
+ def index
6
+ @advertisers = Advertiser.all
7
+ end
8
+
9
+ # GET /advertisers/1
10
+ def show
11
+ end
12
+
13
+ # GET /advertisers/new
14
+ def new
15
+ @advertiser = Advertiser.new
16
+ end
17
+
18
+ # GET /advertisers/1/edit
19
+ def edit
20
+ end
21
+
22
+ # POST /advertisers
23
+ def create
24
+ @advertiser = Advertiser.new(advertiser_params)
25
+
26
+ if @advertiser.save
27
+ redirect_to @advertiser, notice: 'Advertiser was successfully created.'
28
+ else
29
+ render :new
30
+ end
31
+ end
32
+
33
+ # PATCH/PUT /advertisers/1
34
+ def update
35
+ if @advertiser.update(advertiser_params)
36
+ redirect_to @advertiser, notice: 'Advertiser was successfully updated.'
37
+ else
38
+ render :edit
39
+ end
40
+ end
41
+
42
+ # DELETE /advertisers/1
43
+ def destroy
44
+ @advertiser.destroy
45
+ redirect_to advertisers_url, notice: 'Advertiser was successfully destroyed.'
46
+ end
47
+
48
+ private
49
+ # Use callbacks to share common setup or constraints between actions.
50
+ def set_advertiser
51
+ @advertiser = Advertiser.find(params[:id])
52
+ end
53
+
54
+ # Only allow a trusted parameter "white list" through.
55
+ def advertiser_params
56
+ params.require(:advertiser).permit(:name, :contact_name, :contact_email, :description, :epom_id)
57
+ end
58
+ end
@@ -0,0 +1,5 @@
1
+ class ApplicationController < ActionController::Base
2
+ # Prevent CSRF attacks by raising an exception.
3
+ # For APIs, you may want to use :null_session instead.
4
+ protect_from_forgery with: :exception
5
+ end
@@ -0,0 +1,58 @@
1
+ class CampaignsController < ApplicationController
2
+ before_action :set_campaign, only: [:show, :edit, :update, :destroy]
3
+
4
+ # GET /campaigns
5
+ def index
6
+ @campaigns = Campaign.all
7
+ end
8
+
9
+ # GET /campaigns/1
10
+ def show
11
+ end
12
+
13
+ # GET /campaigns/new
14
+ def new
15
+ @campaign = Campaign.new
16
+ end
17
+
18
+ # GET /campaigns/1/edit
19
+ def edit
20
+ end
21
+
22
+ # POST /campaigns
23
+ def create
24
+ @campaign = Campaign.new(campaign_params)
25
+
26
+ if @campaign.save
27
+ redirect_to @campaign, notice: 'Campaign was successfully created.'
28
+ else
29
+ render :new
30
+ end
31
+ end
32
+
33
+ # PATCH/PUT /campaigns/1
34
+ def update
35
+ if @campaign.update(campaign_params)
36
+ redirect_to @campaign, notice: 'Campaign was successfully updated.'
37
+ else
38
+ render :edit
39
+ end
40
+ end
41
+
42
+ # DELETE /campaigns/1
43
+ def destroy
44
+ @campaign.destroy
45
+ redirect_to campaigns_url, notice: 'Campaign was successfully destroyed.'
46
+ end
47
+
48
+ private
49
+ # Use callbacks to share common setup or constraints between actions.
50
+ def set_campaign
51
+ @campaign = Campaign.find(params[:id])
52
+ end
53
+
54
+ # Only allow a trusted parameter "white list" through.
55
+ def campaign_params
56
+ params.require(:campaign).permit(:name, :advertiser_id, :description, :weight)
57
+ end
58
+ end
@@ -0,0 +1,2 @@
1
+ module AdvertisersHelper
2
+ end
@@ -0,0 +1,2 @@
1
+ module ApplicationHelper
2
+ end
@@ -0,0 +1,2 @@
1
+ module CampaignsHelper
2
+ end
@@ -0,0 +1,3 @@
1
+ class Advertiser < ActiveRecord::Base
2
+ acts_as_advertiser epom_id: 'id', name: 'name', contact_name: 'contactName', contact_email: 'contactEmail', description: 'description'
3
+ end
@@ -0,0 +1,3 @@
1
+ class Campaign < ActiveRecord::Base
2
+ acts_as_campaign epom_id: 'id', name: 'name', description: 'description', advertiser_id: 'advertiserId', weight: 'weight'
3
+ end
@@ -0,0 +1,37 @@
1
+ <%= form_for(@advertiser) do |f| %>
2
+ <% if @advertiser.errors.any? %>
3
+ <div id="error_explanation">
4
+ <h2><%= pluralize(@advertiser.errors.count, "error") %> prohibited this advertiser from being saved:</h2>
5
+
6
+ <ul>
7
+ <% @advertiser.errors.full_messages.each do |message| %>
8
+ <li><%= message %></li>
9
+ <% end %>
10
+ </ul>
11
+ </div>
12
+ <% end %>
13
+
14
+ <div class="field">
15
+ <%= f.label :name %><br>
16
+ <%= f.text_field :name %>
17
+ </div>
18
+ <div class="field">
19
+ <%= f.label :contact_name %><br>
20
+ <%= f.text_field :contact_name %>
21
+ </div>
22
+ <div class="field">
23
+ <%= f.label :contact_email %><br>
24
+ <%= f.text_field :contact_email %>
25
+ </div>
26
+ <div class="field">
27
+ <%= f.label :description %><br>
28
+ <%= f.text_area :description %>
29
+ </div>
30
+ <div class="field">
31
+ <%= f.label :epom_id %><br>
32
+ <%= f.number_field :epom_id %>
33
+ </div>
34
+ <div class="actions">
35
+ <%= f.submit %>
36
+ </div>
37
+ <% end %>
@@ -0,0 +1,6 @@
1
+ <h1>Editing Advertiser</h1>
2
+
3
+ <%= render 'form' %>
4
+
5
+ <%= link_to 'Show', @advertiser %> |
6
+ <%= link_to 'Back', advertisers_path %>
@@ -0,0 +1,35 @@
1
+ <p id="notice"><%= notice %></p>
2
+
3
+ <h1>Listing Advertisers</h1>
4
+
5
+ <table>
6
+ <thead>
7
+ <tr>
8
+ <th>Name</th>
9
+ <th>Contact name</th>
10
+ <th>Contact email</th>
11
+ <th>Description</th>
12
+ <th>Epom</th>
13
+ <th colspan="3"></th>
14
+ </tr>
15
+ </thead>
16
+
17
+ <tbody>
18
+ <% @advertisers.each do |advertiser| %>
19
+ <tr>
20
+ <td><%= advertiser.name %></td>
21
+ <td><%= advertiser.contact_name %></td>
22
+ <td><%= advertiser.contact_email %></td>
23
+ <td><%= advertiser.description %></td>
24
+ <td><%= advertiser.epom_id %></td>
25
+ <td><%= link_to 'Show', advertiser %></td>
26
+ <td><%= link_to 'Edit', edit_advertiser_path(advertiser) %></td>
27
+ <td><%= link_to 'Destroy', advertiser, method: :delete, data: { confirm: 'Are you sure?' } %></td>
28
+ </tr>
29
+ <% end %>
30
+ </tbody>
31
+ </table>
32
+
33
+ <br>
34
+
35
+ <%= link_to 'New Advertiser', new_advertiser_path %>
@@ -0,0 +1,5 @@
1
+ <h1>New Advertiser</h1>
2
+
3
+ <%= render 'form' %>
4
+
5
+ <%= link_to 'Back', advertisers_path %>
@@ -0,0 +1,29 @@
1
+ <p id="notice"><%= notice %></p>
2
+
3
+ <p>
4
+ <strong>Name:</strong>
5
+ <%= @advertiser.name %>
6
+ </p>
7
+
8
+ <p>
9
+ <strong>Contact name:</strong>
10
+ <%= @advertiser.contact_name %>
11
+ </p>
12
+
13
+ <p>
14
+ <strong>Contact email:</strong>
15
+ <%= @advertiser.contact_email %>
16
+ </p>
17
+
18
+ <p>
19
+ <strong>Description:</strong>
20
+ <%= @advertiser.description %>
21
+ </p>
22
+
23
+ <p>
24
+ <strong>Epom:</strong>
25
+ <%= @advertiser.epom_id %>
26
+ </p>
27
+
28
+ <%= link_to 'Edit', edit_advertiser_path(@advertiser) %> |
29
+ <%= link_to 'Back', advertisers_path %>
@@ -0,0 +1,33 @@
1
+ <%= form_for(@campaign) do |f| %>
2
+ <% if @campaign.errors.any? %>
3
+ <div id="error_explanation">
4
+ <h2><%= pluralize(@campaign.errors.count, "error") %> prohibited this campaign from being saved:</h2>
5
+
6
+ <ul>
7
+ <% @campaign.errors.full_messages.each do |message| %>
8
+ <li><%= message %></li>
9
+ <% end %>
10
+ </ul>
11
+ </div>
12
+ <% end %>
13
+
14
+ <div class="field">
15
+ <%= f.label :name %><br>
16
+ <%= f.text_field :name %>
17
+ </div>
18
+ <div class="field">
19
+ <%= f.label :advertiser_id %><br>
20
+ <%= f.number_field :advertiser_id %>
21
+ </div>
22
+ <div class="field">
23
+ <%= f.label :description %><br>
24
+ <%= f.text_area :description %>
25
+ </div>
26
+ <div class="field">
27
+ <%= f.label :weight %><br>
28
+ <%= f.number_field :weight %>
29
+ </div>
30
+ <div class="actions">
31
+ <%= f.submit %>
32
+ </div>
33
+ <% end %>
@@ -0,0 +1,6 @@
1
+ <h1>Editing Campaign</h1>
2
+
3
+ <%= render 'form' %>
4
+
5
+ <%= link_to 'Show', @campaign %> |
6
+ <%= link_to 'Back', campaigns_path %>
@@ -0,0 +1,33 @@
1
+ <p id="notice"><%= notice %></p>
2
+
3
+ <h1>Listing Campaigns</h1>
4
+
5
+ <table>
6
+ <thead>
7
+ <tr>
8
+ <th>Name</th>
9
+ <th>Advertiser</th>
10
+ <th>Description</th>
11
+ <th>Weight</th>
12
+ <th colspan="3"></th>
13
+ </tr>
14
+ </thead>
15
+
16
+ <tbody>
17
+ <% @campaigns.each do |campaign| %>
18
+ <tr>
19
+ <td><%= campaign.name %></td>
20
+ <td><%= campaign.advertiser_id %></td>
21
+ <td><%= campaign.description %></td>
22
+ <td><%= campaign.weight %></td>
23
+ <td><%= link_to 'Show', campaign %></td>
24
+ <td><%= link_to 'Edit', edit_campaign_path(campaign) %></td>
25
+ <td><%= link_to 'Destroy', campaign, method: :delete, data: { confirm: 'Are you sure?' } %></td>
26
+ </tr>
27
+ <% end %>
28
+ </tbody>
29
+ </table>
30
+
31
+ <br>
32
+
33
+ <%= link_to 'New Campaign', new_campaign_path %>
@@ -0,0 +1,5 @@
1
+ <h1>New Campaign</h1>
2
+
3
+ <%= render 'form' %>
4
+
5
+ <%= link_to 'Back', campaigns_path %>