@@ -25,7 +25,7 @@ class MissionsController < ApplicationController |
||
25 | 25 |
end |
26 | 26 |
|
27 | 27 |
def show_agent_details |
28 |
- @mission = Mission.find(params[:id]) |
|
28 |
+ @mission = Mission.friendly.find(params[:id]) |
|
29 | 29 |
@agent = @mission.mission_agents.find(params[:agent]) |
30 | 30 |
end |
31 | 31 |
|
@@ -97,11 +97,11 @@ class MissionsController < ApplicationController |
||
97 | 97 |
private |
98 | 98 |
# Use callbacks to share common setup or constraints between actions. |
99 | 99 |
def set_mission |
100 |
- @mission = Mission.find(params[:id]) |
|
100 |
+ @mission = Mission.friendly.find(params[:id]) |
|
101 | 101 |
end |
102 | 102 |
|
103 | 103 |
# Never trust parameters from the scary internet, only allow the white list through. |
104 | 104 |
def mission_params |
105 |
- params.require(:mission).permit(:mission_agents_id, :title, :objective, :briefing, :owner_id, :status, :launched, :language, :cover_img) |
|
105 |
+ params.require(:mission).permit(:mission_agents_id, :title, :objective, :briefing, :owner_id, :status, :launched, :language, :cover_img, :slug, :end_date) |
|
106 | 106 |
end |
107 | 107 |
end |
@@ -1,5 +1,9 @@ |
||
1 | 1 |
class Mission < ActiveRecord::Base |
2 | 2 |
|
3 |
+ extend FriendlyId |
|
4 |
+ friendly_id :title, use: :slugged |
|
5 |
+ validates_presence_of :title, :slug |
|
6 |
+ |
|
3 | 7 |
belongs_to :owner, :class_name => "User" |
4 | 8 |
has_many :mission_agents, :dependent => :destroy |
5 | 9 |
has_many :agent_steps, :through => :mission_agents |
@@ -1,6 +1,5 @@ |
||
1 | 1 |
if Rails.env.production? || Rails.env.test? |
2 |
- uri = URI.parse('http://localhost:6379') |
|
3 |
- REDIS_WORKER = Redis.new(host: uri.host, port: uri.port) |
|
2 |
+ REDIS_WORKER = Redis.new(:host => 'localhost', :port => 6379) |
|
4 | 3 |
else |
5 | 4 |
uri = URI.parse(ENV["REDISTOGO_URL"]) |
6 | 5 |
REDIS_WORKER = Redis.new(host: uri.host, port: uri.port, password: uri.password) |
@@ -0,0 +1,6 @@ |
||
1 |
+class AddSlugToMissions < ActiveRecord::Migration |
|
2 |
+ def change |
|
3 |
+ add_column :missions, :slug, :string |
|
4 |
+ add_column :missions, :end_date, :datetime |
|
5 |
+ end |
|
6 |
+end |
@@ -11,7 +11,7 @@ |
||
11 | 11 |
# |
12 | 12 |
# It's strongly recommended that you check this file into your version control system. |
13 | 13 |
|
14 |
-ActiveRecord::Schema.define(version: 20150129033808) do |
|
14 |
+ActiveRecord::Schema.define(version: 20150214042702) do |
|
15 | 15 |
|
16 | 16 |
# These are extensions that must be enabled in order to support this database |
17 | 17 |
enable_extension "plpgsql" |
@@ -130,6 +130,8 @@ ActiveRecord::Schema.define(version: 20150129033808) do |
||
130 | 130 |
t.string "cover_img" |
131 | 131 |
t.datetime "created_at" |
132 | 132 |
t.datetime "updated_at" |
133 |
+ t.string "slug" |
|
134 |
+ t.datetime "end_date" |
|
133 | 135 |
end |
134 | 136 |
|
135 | 137 |
add_index "missions", ["mission_agents_id"], name: "index_missions_on_mission_agents_id", using: :btree |