Recent Posts

Subscribe to Recent Posts 485 post(s) found

Pages: 1 2 3 4 5 6 7 8 9 10 11 12 ... 20

Jul 24, 2009
Avatar GruffDavies 7 post(s)

Topic: Exercisr Discussion / An error adding activities.

No, it seems I lied about the routes thing. Read it somewhere, maybe it’s an edge rails thing.

 
Jul 24, 2009
Avatar GruffDavies 7 post(s)

Topic: Exercisr Discussion / An error adding activities.

I think you can also use a more concise method on config/routes.rb to map subordinate routes like this:

map.resources :workouts :has_many => :activities

instead of
map.resources :workouts do |workout|
  workout.resources :activities
end

 
Jul 24, 2009
Avatar GruffDavies 7 post(s)

Topic: Exercisr Discussion / An error adding activities.

and change the workout show view to look like:

<h1><%= h @workout.label %> Workout on <%= h @workout.date.to_s(:long) %> </h1> 
<table>
   <tr><th>Exercise</th><th>Reps</th><th>Resistance</th></tr>
   <%= render :partial => 'activities/activity', :collection => @activities %> 
</table> 

<h3>Add Exercise to this Workout</h3> 
<% form_for(:activity, :url => workout_activities_path(@workout)) do |f| %>
   <%= render :partial => 'activities/form', :locals => {:f => f} %> 
<% end %> 

<%= link_to 'Back', workouts_path %>

 
Jul 24, 2009
Avatar GruffDavies 7 post(s)

Topic: Exercisr Discussion / An error adding activities.

There are two file changes needed to get it to work.

1. change the _activity partial to look like:

<tr> 
  <td><%= activity.exercise.name %></td> 
  <td><%= activity.repetitions %></td> 
  <td><%= activity.resistance %></td> 
  <td><%=link_to image_tag("edit_photo.gif", {:title => "Edit Exercise"}), edit_workout_activity_path(@workout, activity) %></td> 
  <td><%= link_to image_tag("delete_photo.gif", {:title => "Delete Exercise"}), workout_activity_path(@workout, activity), 
                                                 :confirm => 'Are you sure?', 
                                                 :method => :delete %> </td> 
</tr> 

 
Jul 24, 2009
Avatar GruffDavies 7 post(s)

Topic: Exercisr Discussion / An error adding activities.

Sorry, my post got munged as I didn’t escape my code samples.

 
Jul 24, 2009
Avatar GruffDavies 7 post(s)

Topic: Exercisr Discussion / An error adding activities.

I fixed it. The tutorial code is wrong in several places. If you run “rake routes” you can inspect the routes created and also the named path helpers. The code is specifying the wrong helpers in a few places.

1. In the the app/views/show.html.erb the :url should be HTH

Gruff

 
Jul 24, 2009
Avatar GruffDavies 7 post(s)

Topic: Exercisr Discussion / An error adding activities.

I’m having exactly the same problem. Any ideas?

Thanks

Gruff

 
Jul 2, 2009
Avatar isharan 2 post(s)

Topic: MonkeyTasks Discussion / CSS not working in Safari 4

Never mind, turns out I was using the wrong version of reset-fonts-grids.css

But you should still write an advanced rails book :)

 
Jul 2, 2009
Avatar isharan 2 post(s)

Topic: MonkeyTasks Discussion / CSS not working in Safari 4

Hey Eldon,

I just finished your other book, Foundation Rails 2, and now I’m reading this one. Great book!

Anyways, the site layout isn’t working properly in Safari 4 (10.5.7). Just downloaded the source files from Apress’ website and made application.rhtml and index.rhtml. When I added index.rhtml, the site navigation bar dissapears. The html is there in the source, but its not showing up. Any ideas? Known bug?

Thanks!

P.S. You should write an advanced rails book.

 
Jun 25, 2009
Avatar mongo 8 post(s)

Topic: MonkeyTasks Discussion / sortable_element... "No action responded to sort."

Sorry. It was a copy and paste typo in my response to the original post. I have since edited my post.

 
Jun 24, 2009
Avatar mongo 8 post(s)

Topic: Exercisr Discussion / An error adding activities.

Eldon,

Thank you so much for taking the time to look at this, and the most helpful book. Tell your publisher there is an increasing demand for an updated version…

I have zipped up the exercisr directory and emailed it to an alameda eldon gmail account. I’m using mysql, so no db is included in the file.

Please don’t spend a whole lot of time looking at this, as me struggling to figure it out is all part of the learning experience. I do appreciate any tips or pointers in the general direction to look.

If I understand the concepts correctly, things like workout_id are automatically generated and set up based upon the relationships defined in the models of the related objects. In this case between an activity and a workout. I’m sure its something simple.

 
Jun 24, 2009
Avatar EldonAlameda 216 post(s)

Topic: MonkeyTasks Discussion / sortable_element... "No action responded to sort."

Were you able to get this working? I’m not seeing the difference in the two lines of code that you posted.

 
Jun 24, 2009
Avatar EldonAlameda 216 post(s)

Topic: Cool Stuff / Fun Ruby Puzzles

Yeah – unfortunately it doesn’t seem like the writer of the blog continued it. Too bad it was a fun idea.

 
Jun 24, 2009
Avatar EldonAlameda 216 post(s)

Topic: Introductions / Greetings

Thanks – I do try to continue to help people as best as I can. Obviously I’m not checking the site as regularly as I used to but I do try to login here at least once a week and respond to any questions.

 
Jun 24, 2009
Avatar EldonAlameda 216 post(s)

Topic: Introductions / just wonderful!!!

Thanks!

 
Jun 24, 2009
Avatar EldonAlameda 216 post(s)

Topic: Exercisr Discussion / An error adding activities.

mongo,

if you want to zip up the application and email it to me, I’ll take a look at this weekend and let you know what the issues are.

—Eldon

 
Jun 24, 2009
Avatar mongo 8 post(s)

Topic: Cool Stuff / Fun Ruby Puzzles

FYI – The link is no longer valid at the time this was posted.

 
Jun 24, 2009
Avatar mongo 8 post(s)

Topic: Introductions / Greetings

And thanks for supporting your work! I’m amazingly impressed that Eldon is still monitoring these forums, years after the books was published. Not too many people would take the time.

 
Jun 24, 2009
Avatar mongo 8 post(s)

Topic: Exercisr Discussion / An error adding activities.

I’m about halfway through the Exercisr. I am at the point where I’m trying to add an activity to a workout. Everything seems to be fine until I attempt to Save the activity.

(Sorry, but I am using more current versions that what is prescribed in the book:
On Ubuntu linux, ruby 1.8.7, rails 2.3.2, and MySQL rather than SQLLite. So far these versions have not caused any problems.)

I get this error message:

Couldn't find Workout without an ID

from this application trace:

/home/phil/.gem/ruby/1.8/gems/activerecord-2.3.2/lib/active_record/base.rb:1572:in `find_from_ids'
/home/phil/.gem/ruby/1.8/gems/activerecord-2.3.2/lib/active_record/base.rb:616:in `find'
/home/phil/.gem/ruby/1.8/gems/activerecord-2.3.2/lib/active_record/associations/association_collection.rb:60:in `find'
/home/phil/www/exercisr/app/controllers/activities_controller.rb:92:in `find_workout'

I’m a little confused as to where the workout_id comes from in the protected method find_workout in the activities_controller.

My model objects looks like this:

class Workout < ActiveRecord::Base
  belongs_to :user
  has_many :activities, :dependent => :destroy
  has_many :exercises, :through => :activities
  validates_presence_of :date
end

class Activity < ActiveRecord::Base
  belongs_to :exercise
  belongs_to :workout
  validates_presence_of :resistance, :repititions
  attr_accessor :new_exercise_name
  before_save :create_exercise_if_submitted

  def create_exercise_if_submitted
    create_exercise(:user_id => workout.user_id, :name => new_exercise_name) unless new_exercise_name.blank?
  end

end

(I know repetition is spelled incorrectly, but it is incorrect consistently within the application).

Can anyone point me in a direction where to look as to why the find_workout is not happening? Is it that I am somewhere somehow not passing a workout object to the activity controller?

 
Jun 16, 2009
Avatar mongo 8 post(s)

Topic: Introductions / Greetings

I’m late to the Rails party, but hope to catch up quickly. I’m only up to MonkeyTasks, but so far, so good.

Thanks to all for the helpful information, both in the book, and on the forums.

 
Jun 16, 2009
Avatar mongo 8 post(s)

Topic: MonkeyTasks Discussion / sortable_element... "No action responded to sort."

It appears you may have a typo. I believe the line you have as

todo.position = params['todo_list'.index(todo.id.to_s) + 1]

should be like this (note where the closing right brace is):
todo.position = params['todo_list'.index(todo.id.to_s)] + 1

Hope that helps. I’m just getting started on this whole Ruby/Rails thing so take any posts I enter with a grain of salt…

 
Jun 9, 2009
Avatar aniruddha 1 post

Topic: Introductions / just wonderful!!!

hi Eldon Alameda…i just bought your book yesterday evening…jus wanted to tell you rails projects is the next best thing to ror :)...

 
May 26, 2009
Avatar Scott 1 post

Topic: MonkeyTasks Discussion / sortable_element... "No action responded to sort."

I believe I have copied the code correctly from the book on this one, but when I try to sort items by dragging and dropping, the server pipes up with an ActionController::UnknownAction, claiming that nothing would respond to sort. :(

Is this caused by using Rails 2.3.2?

in index.html.erb:

<%= sortable_element ‘todo-list’, :url => { :action => “sort”, :id => @today }, :complete => visual_effect(:highlight, ‘todo-list’) %>

in today_controller.rb:

def sort
  @today.todos.each do |todo|
    todo.position = params['todo_list'.index(todo.id.to_s) +1]
    todo.save
  end
  render :nothing => true
end
 
Apr 17, 2009
Avatar AlanF 10 post(s)

Topic: MonkeyTasks Discussion / Where does "salt" come from?

Good suggestion. I went back in and added some HTML “pre” tags.

 
Apr 15, 2009
Avatar EldonAlameda 216 post(s)

Topic: MonkeyTasks Discussion / Where does "salt" come from?

Yeah – unfortunately i don’t think there’s anyone actively developing Beast anymore and I have too many projects going to dig too deep into the source and make patches for it.

Personally I avoid the block quotes and simply add in standard HTML pre tags around the content i want quoted (manually adding in line breaks as necessary). I like the way those look better than the way the block quotes look.

Next Page

Pages: 1 2 3 4 5 6 7 8 9 10 11 12 ... 20