I'm trying to write a test for a model with a picture, using paperclip. I'm using the test framework default, no shoulda or rspec. In this context, how should I test it? Should I really upload a file? How should I add a file to the fixture?
...
Hopefully something less newbish than my last...
Anyhow, I am doing a bit of coding on a small app that simplifies numbers down to primes, mainly to help with small things like homework.
However, a particular method is giving me the error mentioned in the title:
def get_simps(num)
curr = 2
print("Working...")
while (curr <...
string.sub looks like it only replaces the first instance. Is there an option for that or another method that can replace all patterns? Can you do it inside a regex like perl?
(I think something like r/blah/blah/)
... and +1 to anyone who can tell me WHY ON EARTH does string.sub replace just the FIRST match?
...
Is there a framework or something out there so that I can develop webpages in Ruby the same way I can as PHP. Something like
<html><head></head><body>
<?ruby
puts '<p> Hello there!</p>'
?>
</body></html>
The only thing I'm seeing for using Ruby in webpages is huge complex frameworks that is completely different from how PHP works. I...
I've developed a web based point of sale system for one of my clients in Ruby on Rails with MySQL backend. These guys are growing so fast that they are ringing close to 10,000 transactions per day corporate-wide. For this question, I will use the transactions table as an example. Currently, I store the transactions.status as a string ...
I'm relatively new to RoR (my first experience far from pleasant) and just stuck with a simple file upload application.
When I upload file I can see a temp file created on the server but it's smaller than the file I upload. I assume I get this error 'cause browser just closes connection on me before the whole file gets transmitted ( it h...
Hi,
I have a base class which contains an equal? method. I've then inherited that object and want to use the equal? method in the super class as part of the equal? method in the sub class.
class A
@a
@b
def equal?(in)
if(@a == in.a && @b == in.b)
true
else
false
end
end
...
what i want is a way of nesting partial properties, this seems a tad long winded:
= partial('frames/tabs_a', :locals => {:tabs_title => 'semi-dynamic-tabs',
:tabs_id => 'p001',
:panel_a => 'views/article-highlights_a',
:a_id => 'p_002_0',
:a_ft => '123 More in highlights',
:a_tt => 'panel a',
:a_c => 'magazine',
:panel_b...
I'll start in the beginning of the next year (2010) a big new project with Rails. Can somebody give me advice which version of Rails I should use and why?
...
How can I open a file and search for a word inside it using Ruby?
...
I was following the screencast on rubyonrails.org (creating the blog).
I have following models:
comment.rb
class Comment < ActiveRecord::Base
belongs_to :post
validates_presence_of :body # I added this
end
post.rb
class Post < ActiveRecord::Base
validates_presence_of :body, :title
has_many :comments
end
Relations ...
I'm trying to extract subtitles from unencrypted DVDs with a program, so I can save them seperately. I know there are programs that do that (I found this page for example: http://www.bunkus.org/dvdripping4linux/en/separate/subtitles.html), but I would like to be able to do it with a library call or something like that (do libdvdread or l...
Been playing with Ruby on Rails for awhile and decided to take a look through the actual source. Grabbed the repo from GitHub and started looking around. Came across some code that I am not sure what it does or what it references. Can anyone tell me what the dollar sign ($) character does in Ruby?
I saw this code in actionmailer/test/ab...
A frequent task I run into at work is writing scripts against pre-existing databases. Sometimes I'm connecting to Oracle, other times it might be MySql or even sql server.
What I would like is a tool which would reverse-engineer the database's tables and foreign keys and allow me to write OO-style scripts against the database. This coul...
Is there a way that I can have auto completion in Vim after I load a model from the database?
So for example if I have a model of type Foo with an instance method of type bar and do the following
foo = Foo.first(:param=>'x')
foo.b
should show me bar as a possible auto complete value. I think that this is somewhat hard to accomplish wi...
hi
i am trying to ensure that the username is unique when registering but im not sure how to do this
I've tried:
validates_uniqueness_of :username
but it doesnt work
it gives me this error:
undefined method 'validates_uniqueness_of' for #<UsersController:0x6c4fd2>
Any help please?
...
Hi. I have a class with a constant defined for it. I then have a class method defined that accesses that class constant. This works fine. An example:
#! /usr/bin/env ruby
class NonInstantiableClass
Const = "hello, world!"
class << self
def shout_my_constant
puts Const.upcase
end
end
...
If I built an application that accessed some of the data from say Gmail, Twitter and Facebook, and I want the user to be able to only have to enter their authentication info once, and it's reset after some days or weeks, what is the best way to do this, dynamically, in Ruby?
I see a lot of people just having a config file of their clien...
I'm using the Highrise API and Ruby wrapper, but my problem is that (besides having a nightmare of a time with the API it self) I want to search a hash that is returned for something:
>> Highrise::Person.find(:all).detect{|p| p.name == 'Brandon'}
=> [#<Highrise::Person:0x102a4d2f8 @prefix_options={}, @attri....
I can do that but obvio...
Using Mechanize with Ruby I get a certain file using agent.get('http://example.com/foo.torrent'), with FileUtils or otherwise, how do I save this file to my hard drive (for instance, in a directory wherefrom the script is running)?
P.S. class => WWW::Mechanize::File
...