I'm currently using Rcov to get C0 code coverage analysis for a rails project that I'm working on.
However, those results are practically meaningless- I have 100% coverage according to rcov (as it only covers C0 analysis) and I've barely written half the test cases for the functionality that exists thus far.
I'm used to the useful resu...
I am new to RESTful stuff. But, I want to use it in my rails app. When I add this to my routes.rb map.resources :notes I get routes to these methods created:
index
create
new
edit
show
update
destroy
What I am wondering is what is the difference between edit/update and create/new? Is there any standard definitions of how these met...
Are there any things to be careful about when defining the method_missing method in Ruby? I'm wondering whether there are some not-so-obvious interactions from inheritance, exception throwing, performance, or anything else.
...
Is Rails development really this hard on Windows? I'm a PHP developer looking forwards to using Rails (mainly because every single PHP framework I've tried has some quirk that I just hate).
I downloaded Aptana Studio (w/ RadRails) as it seemed to be a good solution (and because I love anything Eclipse-based). But that's where the proble...
Hi,
I have an application where I'm dynamically loading routes by a model, and calling ActionController::Routing::Routes.reload! after creating/updating that model. The problem is that after doing this, I'm receiving the following error when I try to hit that new route:
ActionController::MethodNotAllowed
Only get, head, post, put, and...
Say that I have two models- Users and Accounts. Each account can have at most n users associated with it, and a user can only be associated with one account.
It would seem natural to say that User
belongs_to :account
and Account
has_many :users
However, I'm not clear on the best practice when it comes to limiting the number of ...
I'm looking into the feasibility of adding a function to my Rails-based intranet site that allows users to upload files.
Two purposes:
My users are widely distributed geographically and linking to documents on the shared network storage doesn't always work (different addresses, DNS entries and stuff outside my control or interest) so I'...
I'm not sure how to search for this answer, so I'll go ahead and ask it.
In my rails project I have a User model and a foo model. A user can have one or more foo models assigned to it. I have accomplished this by adding
has_many :foo, :through => :user_foo
in my user model.
Now, over in my view, I want to display a list of all foo...
How do you add a Hyperlink to a word document using an existing bookmark. I have been testing using IRB but continue to get Command Failed.
I have attached to a running word application have text selected that I want to tie to the hyperlink. For testing I have been trying to just add a google hyperlnk. I figure once I get that then I wo...
I'm slowly moving from PHP5 to Python on some personal projects, and I'm currently loving the experience. Before choosing to go down the Python route I looked at Ruby. What I did notice from the ruby community was that monkey-patching was both common and highly-regarded. I also came across a lot of horror stories regarding the trials of ...
I have a Rails app with some basic models. The website displays data retrieved from other sources. So I need to write a Ruby script that creates new instances in my database. I know I can do that with the test hooks, but I'm not sure that makes sense here.
I'm not sure what this task should look like, how I can invoke it, or where it sh...
We have built a custom socket server in ruby and packaged it as a gem. Since this is an internal project we can not simply publish it to RubyForge or GitHub. I tried to setup our own gem server but gem would not authenticate over https. Our other deployment is all for standard rails applications that use capistrano and svn for deployme...
I'd like to mark a method as deprecated, so the people using it can easily check their code and catch up. In Java you set @Deprecated and everybody knows what this means.
So is there a preferred way (or even tools) to mark and check for deprecations in Ruby?
...
When I generate a default scaffold, the display tags on show.html.erb have
<%=h @broker.name %>
I know the difference between <% and <%=. What's the "h" do?
...
How can I prevent the image tag that calls the associated image from displaying if no image is associated with the record?
<%= image_tag @agent.avatar.url %>
...gives me the text "Missing" if there is no image associated with that agent. I want to test to see there is an image available first, then render the above tag if the test re...
If I have...
class Bunny < ActiveRecord::Base
has_many :carrots
end
...how can I check in the View if @bunny has any carrots? I want to do something like this:
<% if @bunny.carrots? %>
<strong>Yay! Carrots!</strong>
<% for carrot in @bunny.carrots %>
You got a <%=h carrot.color %> carrot!<br />
<% end %>
<% end %>
I kn...
When trying to work with Qt's signal/slot mechanisms over more than one level of inheritance, I ran into a problem: When my class does not directly inherit from QObject, signals and slots don't seem to work any more.
The output of the following program illustrates the case:
require 'Qt'
class A < Qt::Object
signals 'mySignal()'
sl...
I'm using DRb within a Rails application to offload an expensive task outside the Rails process. Before initializing the client stub with DRbObject.new it is necessary to initialize the DRb service with DRb.start_service.
Doing this in model or controller appears to leave threads in an uncertain state. When I exit mongrel it says:
Reap...
Here's the code:
render :file => @somedir + "/blah.xml"
...but the resulting MIME type is text/html when I check in FireBug. How do I specify a MIME type in this case?
...
I have a FooController that responds to HTML and JS (AJAX) queries:
# app/controllers/foo_controller.rb:
class FooController < ApplicationController
layout 'foo'
def bar
respond_to do |format|
format.html # foo/bar.html.erb
format.js # foo/bar.js.erb
end
end
end
The templates to support it:
# app/views/lay...