Feb 23
This error is extremely frustrating. It occurs when the .svn info is missing in a directory. In my example this happens when running ‘rake doc:app’ and I have found only one sequence that will fix this. In my case, I am removing doc from subversion and going to manage outside of source control.
To fix:
- cd /doc/app
- mv ‘app’ ‘app-todelete’
- do a new checkout from svn just on the directory you renamed. Like so:
svn co svn+ssh://usery@mysecre.server.com/var/www/apps/repos/trunk/doc/app
- The newest version in source should be in the proper location.
- You will unfortunately have to merge any changes from the old directory, as in my case ‘app-todelete’
Enjoy!
Tagged with: Rails • subversion
Feb 10
Soon the rest of this blog will deal with a basic overview of has_many associations and a practical use. For now look at this simple tag that uses has_many of a Blog model to show the Interests (or topics) for a given blog. You would use this helper_tag like so in your view, given that you have a single instance of a blog object called ‘blog’
<%= more_ugly_interests_tag(blog) %>
I hope this small article might help others:
#########################################
#Tag to show usage of has_many for a model.
#Ruby on Rails
#*this_model* is the actual instance of a blog or photo
#which has a list of interests.
#
#Call tag like this:
# <%= more_ugly_interests_tag(blog) %>
#the syntax below uses what Ruby calls a 'block'
#this is the format:
# some_variable_that_has_a_list.each { |list_item
# #do something with each item
# puts list_item + " !!!!"
# }
#########################################
def more_ugly_interests_tag(this_model)
to_return = "INTERESTS"
this_model.interests.each { |each_interest|
to_return = << each_interest << "
"
}
#now we have end the whole function/method with what we want to return/print
to_return
end
Tagged with: block • helper • helper tags • Rails • ruby
Jan 29
All the Agile folks would say if you run/create your tests you might not even get this far. However, that’s not always reality for me.
1. ‘tail -f /development.log’
If you are on OSX, the above is easy.
On Windows, I’d suggest looking at Cygwin and getting tail working. It’s worth it.
a) open terminal.
b) Clear the screen before you reattempt what is broken. (Use Apple + K on OSX)
c) Stop tail right after getting the error (CTRL + C)
d) Look for the first line that is not normal Rails and debug output. See next area.
2. Skip all the fluff and go for Ruby errors. You will learn to see “stacktraces” and errors in Ruby/Rails after a little practice.
They will look something akin to this:
1)An error
2)The file that the error occurred in…
3)the line number/and problem code…
4)A sample of the code at and around the error.
…
5) A bunch of code that was run prior to this happening.
3. Did you recently change the file in question? If so, revert what you did?
4. Use logger.debug to print out something right before the error to see if your code is making it that far.
Tagged with: 101 • coding • Rails • troubleshooting