How would I quickly debug helper methods in script\console. I'm talking about making changes and then debugging, over and over again.
This is a lot easier with Model methods, since all I have to do is use
reload!
to test the updated code, whereas to test a helper method, I have to do something like this
foo = ActionView::Base.new
foo.e...
I recently became drunk on the Rails koolaid and am trying to create the following:
User model (this is fine)
id
Link model (associated with two Users)
id
user_id1
user_id2
Is this an instance in which I would want to use the has_and_belongs_to_many association type on the Link model? How should I do this?
Ultimately, I would like...
Hey guys,
I am trying to call a java soap webservice within my ruby on rails app. Therefor I use the following code:
email = "[email protected]"
pw = "legendary"
XSD::Charset.encoding = 'UTF8'
wsdlfile = "http://134.60.60.40:8080/FuturecanteenWebservice/DatabaseWSService?wsdl"
driver = SOAP::WSDLDriverFactory.new(wsdlfile).cr...
I have developed contingent country-state select dropdowns, and I'd like to factor out this behavior to an Address model so that I don't have to copy the dynamic behavior (more or less split between view and controller) each and every time I want the user to be able to enter a full address.
Basically I'm trying to dip my toes a little d...
Hello,
I realized that I'm writing a lot of code similar to this one:
<% unless @messages.blank? %>
<% @messages.each do |message| %>
<%# code or partial to display the message %>
<% end %>
<% else %>
You have no messages.
<% end %>
Is there any construct in Ruby and/or Rails that would let me skip that
first condition? So...
I recently started a project where the team decided we'd like to use jQuery rather than Prototype/Scriptaculous for our javascript needs. We set our project up, and began the switch. The plugin was installed via these instructions, and all went according to plan. Shortly after, when trying to run "./script/server", we get the followin...
As I have become more and more comfortable using metaprogramming techniques I have found more and more applications for metaprogramming as well. I'm working now on a little project in which I am creating classes and instances of these classes on the fly and I'm wondering if I have taken metaprogramming too far? Is there such a thing as...
I am using the following code to get the Item from the Rss feed but it only gives me the first item. How can I get all the items:
root.elements["channel/item"].each do |item|
titles << item.text
end
UPDATED:
titles = []
# go through the collection and prints the title
root.elements["channel/item"].each do |item|
...
Hi,
I have textmate 1.5.7 running on my leopard machine.
When programming in rails, for some reason some key words do not get highlighted.
For example: validates_presence_of, has_many, remote_form_for (form_for gets highlighted) etc...
I tried switching themes and it did not help. I also tried upgrading to the most recent rails bundle ...
i changed my .autotest file to use with ruby based project.
after that when i wanted to use it for rails it is using the .autotest configuration settings i used for ruby project.
i uninstalled autotest and reinstalled it with no luck.
i also removed .autotest file in root directory but it is not working.
...
I want links that when hovered over you see the link to look something like this:
http://www.website.com/redirct_to=linkID2
(maybe not exactly like that but try to get the idea)
I have a form area in my blog that I can input a website url but I want to make it redirect_to an external website when it shows the post.
...
I have two scaffold-generated models: Book and Bookbag. A Bookbag has-many Books, and a Book belongs-to a Bookbag. Each Book has a weight, and each Bookbag has an average-weight that is supposed to store the average weight of all of its Books. What is the best way to keep average-weight up to date?
Using a before-save filter on Bookba...
Upon upgrading from a MB to a new MBP, Apple's migration assistant didn't move my gems.
I'm installing rubygems via macports this time, hoping to avoid this upon next upgrade.
Tell me why I'm wrong.
...
I have a rails model class
class Model < ActiveRecord::Base
has_many :object_collection
def add_object(object)
object_collection.push object // works
@object_collection.push object // does not work
self.object_collection.push object // works
end
end
I was wondering if someone can please explain to me why t...
Hello, all, I'm using rdoc to generate documentation for my Ruby code which contains C-extensions, but I'm having problems with my method arguments. Rdoc doesn't parse their names correctly and instead uses p1, p2 etc.
So, first off, my extensions are actually compiled as C++ so I have to use function definitions that look like this:
...
I'm trying to fool a very complex black box into displaying some floats differently (it's the Gruff graphing library, so this is being rendered to an image).
In the console, I can paste this:
logger = RAILS_DEFAULT_LOGGER
logger.debug "Here's a float #{455.67.to_s}"
eval %{class Float
def to_s_with_time
h = (self / 60...
What want to be accomplished is:
I want to "synchronize web browsers". my site has a "wait URL" where when browser gets there it will be kept waiting till another browser also go there and then both will be presented with a quiz-like game.
Right now the wait url will call each second to Rails to check if other player came to the game. H...
Assume we have an usual M-M relationship between two tables, like:
users---< users_tags >--- tags.
In this post I'm only concerned about the relation user_tags, tags: I'd like to avoid that linked tags can be deleted. Only tags which aren't referenced should be destroyable.
The stupid way to do this would be:
class Tag
def before...
Is there a way to check if some gem is currently installed, via the Gem module? From ruby code, not by executing 'gem list'...
To clarify - I don't want to load the library. I just want to check if it's available, so all the 'rescue LoadError' solutions don't help me. Also I don't care if the gem itself will work or not, only whether it...
I get this error trying to run any Ultrasphinx rake commands (under Linux terminal) such as rake ultrasphinx:configure :
rake aborted!
no such file to load -- echoe
/var/www/gitorious/vendor/plugins/ultrasphinx/Rakefile:2:in `require'
/var/www/gitorious/vendor/plugins/ultrasphinx/Rakefile:2
/usr/lib/ruby/1.8/rake.rb:2359:in `load'
/us...