I have a query that pulls stats which I would like to place on the footer of every page of my application. So natural I'm putting it in the application.rb, but the statistics in question don't change throughout the day generally...
Basically in the footer it will say:
Currently, 46 Countries, 75 Cities, and 20,000 locations.
But I w...
I have several ruby and rails projects hosted in GitHub.
I wonder how I could create API documentation for these automatically?
Examples:
http://rake.rubyforge.org/
http://rspec.rubyforge.org/rspec/1.3.0/
Are there tutorials for creating this API docs in Ruby?
...
How do I create a Ruby date object from this string "DD-MM-YYYY"?
...
Hi,
Can any one guide how to search number with wildcard on thinking sphinx...
I have tried, by using
User.search "12", :star => true
which result only 12
but i need to display the number whichever has 12. like prefix and suffix...
...
I am using rvm
rvm list
rvm rubies
jruby-1.5.0 [ i386-java ]
jruby-1.5.1 [ i386-java ]
ruby-1.8.7-p299 [ i386 ]
=> ruby-1.9.2-p0 [ i386 ]
with:
rails -v
Rails 3.0.0.rc
ruby -v
ruby 1.9.2p0 (2010-08-18 revision 29036) [i686-linux]
However, when starting rails (with either webrick or thin), the ruby interpretor used is ru...
I would like to have my Sinatra app include a view specific stylesheet in the layout.
Consider this simple app:
app_folder_root/
| my_app/
| my_app.rb
| public/
| css/
| index.css
| layout.css
| views/
| index.haml
| layout.haml
config.ru
config.ru:
require 'rubygems'
require './my_app/my_app'
map '/' do
run MyApp...
If you use something like each_hash to loop over a Mysql::Result set in Ruby when using the Mysql gem then you end up at the end of the result set and any subsequent each_hash loop doesn't have anything to loop over.
I see there is a Mysql::Result#row_seek method, which expects a Mysql::RowOffset object. But I'm unable to find any docum...
so i'm dealing with a text (in string) containing many year numbers (four-digit), i'm trying to divide the text into segments each of which begins and ends with a year number (doesn't matter if the year number is included in the segment). basically year numbers just act like a signal for the code to 'cut'.
any ideas how i can do that? h...
I have a lot of has_many :through relations in my app. I am extensivley showing informations related to this, such as number of connected objects. Whenever user updates the relation, join table is modified, and I can catch this my Sweepers.
The problem is, that join table entries are deleted, not destroyed. If relation is gone, I have ...
I can't seem to install the MySQL gem. I'm using this command:
ARCHFLAGS="-arch i386" gem install mysql --
--with-mysql-dir=/usr/local/mysql/
--with-mysql-config=/usr/local/mysql-5.1.50-osx10.6-x86/bin/mysql_config
The errors that I am getting seem to indicate that I have no headers and etc. Not sure where I can get those. I'm on Sn...
gem install XXX seems to run the installation process even if the package is already installed. i.e. if I do
$ gem install chef
...
$ gem list | grep chef
chef (0.9.8)
$ gem install chef
...
the second gem install chef seems to install chef again!
How can I get this to result in a noop and the message "chef is already installed", or...
Hi, I've got something like this
class Reply < AR::Base
end
class VideoReply < Reply
def hello
p 'not ok'
end
end
class PostReply < Reply
def hello
p 'ok'
end
end
...
So when I am creating object:
# params[:reply][:type] = "VideoReply"
@reply = Reply.new(params[:reply])
How can I invoke child method (in this case...
I am getting started with Ruby development and bought a MAC few days ago. I am having a hardtime installing the RSpec bundle on my TextMate. When I type the following command:
John-Doe-MacBook-Pro:Users johndoe$ cd ~/Library/ApplicationSupport/TextMate/Bundles/
I get the following:
-bash: cd: /Users/johndoe/Library/ApplicationSuppor...
Starting a new web app with Rails 3. I'm still relatively new to web development and have really enjoyed all the internet resources available to me while working in Ruby 1.8.7 and Rails 2.3.5. Any advice against using Ruby 1.9.2 on my new project?
...
I know I can pass :rel => "nofollow" to link_to but is there a way to set that by default so I don't have to make changes in each link_to tag?
...
I'm trying to figure out an efficient way to provide data to a plotting script jqplot of the amounts of clicks on a certain model
I have the main model: Listing has_many clicks
each click has a datestamp
how can I get a count of clicks created for each day in a date range?
...
Is there a way to compare two arrays and show what is common to both of them?
array1 = ["pig", "dog", "cat"]
array2 = ["dog", "cat", "pig", "horse"]
????
What do I type to show that ["pig", "dog", "cat"] are common between these two arrays?
...
Hi
Sorry i really didn't know how to phrase the question any better but here is my problem:
when i try to update or create a patient object in my rails application the values are not getting sent through to the model, because when i try to create a new patient i get validation errors that i put in place sating i have to enter values (w...
I have a model Ticket which has n Comments belonging to it (many to one relationship).
The issue is that I can not render any of the comments nor does the form post the comments to the database.
I can kinda sorta do this from irb. I can add comments to tickets.comments, but I cannot pull individual comments - I can pull up the collect...
I've been working on a ruby module that interacts with mysql on my server. I need to fetch and write data to the database, and it's been working fine for a while now. However, today I created a new file trying to access the database and it wouldn't run. When I tried to execute it (with command: ruby mysql.rb), I received the following er...