Permalink
Browse files

Steps will display in the correct order now

  • Loading branch information...
1 parent c2286b8 commit 50d1f999ce636c4440db90c5e7bbaa21aa6847b2 @rhuberdeau committed Oct 14, 2011
Showing with 5 additions and 7 deletions.
  1. +1 −1 app/controllers/tutorials_controller.rb
  2. +1 −4 app/models/step.rb
  3. +1 −1 app/models/tutorial.rb
  4. +2 −1 app/views/tutorials/show.html.erb
@@ -15,7 +15,7 @@ def index
# GET /tutorials/1.xml
def show
@tutorial = Tutorial.find_by_permalink(params[:id])
- @steps = @tutorial.steps.order("position")
+ @steps = @tutorial.steps
@next = @steps[0]
@title = "#{@tutorial.name} - A Ruby on Rails tutorial"
respond_to do |format|
View
@@ -9,9 +9,6 @@ class Step < ActiveRecord::Base
private
def assign_position
- @tutorial = self.tutorial
- @position = @tutorial.steps.size
- @position = @position + 1
- self.position = @position
+ self.position = tutorial.steps.size + 1
end
end
View
@@ -1,6 +1,6 @@
class Tutorial < ActiveRecord::Base
attr_accessible :name, :summary, :permalink
- has_many :steps
+ has_many :steps, :order => 'id'
validates :name, :presence => true,
:length => { :maximum => 50 },
@@ -25,6 +25,7 @@
<!--This is filled with the forward and backward links by jquery -->
</div>
<div id="slidesContainer">
- <%= render :partial => @tutorial.steps %>
+ <%= render @steps %>
+
</div>
</div>

0 comments on commit 50d1f99

Please sign in to comment.