@@ -26,7 +26,7 @@ class MissionsController < ApplicationController |
||
26 | 26 |
|
27 | 27 |
def show_agent_details |
28 | 28 |
@mission = Mission.friendly.find(params[:id]) |
29 |
- @agent = @mission.mission_agents.find(params[:agent]) |
|
29 |
+ @agent = @mission.mission_agents.friendly.find(params[:agent]) |
|
30 | 30 |
end |
31 | 31 |
|
32 | 32 |
# GET /missions/new |
@@ -1,4 +1,9 @@ |
||
1 | 1 |
class MissionAgent < ActiveRecord::Base |
2 |
+ |
|
3 |
+ extend FriendlyId |
|
4 |
+ friendly_id :role, use: :slugged |
|
5 |
+ validates_presence_of :role, :slug |
|
6 |
+ |
|
2 | 7 |
belongs_to :mission |
3 | 8 |
belongs_to :user |
4 | 9 |
|
@@ -0,0 +1,5 @@ |
||
1 |
+class AddSlugToMissionAgent < ActiveRecord::Migration |
|
2 |
+ def change |
|
3 |
+ add_column :mission_agents, :slug, :string |
|
4 |
+ end |
|
5 |
+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: 20150214042702) do |
|
14 |
+ActiveRecord::Schema.define(version: 20150216000743) do |
|
15 | 15 |
|
16 | 16 |
# These are extensions that must be enabled in order to support this database |
17 | 17 |
enable_extension "plpgsql" |
@@ -99,6 +99,7 @@ ActiveRecord::Schema.define(version: 20150214042702) do |
||
99 | 99 |
t.text "debriefing" |
100 | 100 |
t.datetime "created_at" |
101 | 101 |
t.datetime "updated_at" |
102 |
+ t.string "slug" |
|
102 | 103 |
end |
103 | 104 |
|
104 | 105 |
add_index "mission_agents", ["agent_steps_id"], name: "index_mission_agents_on_agent_steps_id", using: :btree |