diff --git a/app/controllers/sketches_controller.rb b/app/controllers/sketches_controller.rb
index 4281e78..ffbceeb 100644
--- a/app/controllers/sketches_controller.rb
+++ b/app/controllers/sketches_controller.rb
@@ -15,6 +15,7 @@ def show
def new
@sketch = Sketch.new
+ @challenge_id = params[:challenge_id]
end
def create
diff --git a/app/views/challenges/show.html.erb b/app/views/challenges/show.html.erb
index 9995b2b..e81df2c 100644
--- a/app/views/challenges/show.html.erb
+++ b/app/views/challenges/show.html.erb
@@ -3,7 +3,7 @@
<%= link_to "Vote", challenge_sketches_challenge_path(@challenge), class: "votes-challenge-button" %>
- <%= link_to "Participate", new_sketch_path, class: "participate-challenge-button" %>
+ <%= link_to "Participate", new_sketch_path(challenge_id: @challenge.id), class: "participate-challenge-button" %>
diff --git a/app/views/sketches/_form.html.erb b/app/views/sketches/_form.html.erb
index ba77a88..61949d4 100644
--- a/app/views/sketches/_form.html.erb
+++ b/app/views/sketches/_form.html.erb
@@ -18,7 +18,11 @@
<%= form.label :challenge_id %>
- <%= form.collection_select :challenge_id, Challenge.all, :id, :title, prompt: true %>
+ <% if @challenge_id.present? %>
+ <%= form.collection_select :challenge_id, Challenge.all, :id, :title, { selected: @challenge_id }, promt: true %>
+ <% else %>
+ <%= form.collection_select :challenge_id, Challenge.all, :id, :title, prompt: true %>
+ <% end %>