If I use Sequel in a ruby app like this:
DB = Sequel.sqlite('testdb.db')
does it make the database shared? Can I acces this same file from a different ruby app AT THE SAME TIME and get the database to perform locking etc?
I'm thinking probably not and i'd have to actually have a separate instance of the database running.
thanks
...
Hi,
I must throw my hands up and declare I'm completely stumped on this one!
I have the following models:
Chat:
has_many :messages
Message:
belongs_to :chat, :counter_cache => true
belongs_to :authorable, :polymorphic => true
User:
has_many :messages, :as => :authorable
has_many :chats, :through => :messages, :uniq => true...
I've come up with this:
def f x, &b
yield x, b
end
f 4 do |i, b|
p i
f i - 1, &b if i > 0
end
Result:
4
3
2
1
0
Is there another way?
...
consider the following code:
module ModName
def aux
puts 'aux'
end
end
if we replace 'module' with 'class', we can do the following:
ModName.new.aux
but since modules can't instanced, is there any way to call the 'aux' method?
...
I've been working on an MPD front end in Ruby, with the ability to play a random album.
album = all[(rand*all.length).floor]
Where all is an array of the names of all albums in the library, chooses the album to play.
This works, however, I find it plays some albums more than others, and sometimes very obviously (I've seen it play the...
I am new to rails so go easy. I have developed my blog and deployed it successfully. The entire app is based out of the post_controller. I am wondering how I can reroute the users path to default to the post_controller vs. the app controller.
To illustrate, if you go to http://mylifebattlecry.heroku.com you will see the default rails p...
Hi,
I've a Sinatra app which would be used by different clients. I wish to show the client's Company Logo and a custom layout.erb for each client.
The code base is essentially same for everyone. All I need is a way to easily maintain a different set of files in the 'Public' directory and 'layout.erb', and when deploying to the remote ...
I am using the acts_as_taggable_on gem and would like to add a method to one of the gem source files (tag.rb), but I do not want to change the gem source in any way.
I have tried creating my own tag.rb file to in the /app/models directory or in the /lib directory, and then adding the desired method to that file expecting that ruby will ...
Hopefully the title says it all - I never use ri nor rdoc and they take too long to install. Is there a config file somewhere that will let me do this
...
I'd like my rack application to be able to interface with a server-side javascript engine.
As of now the only way i know this could be possible, is by running JRuby and Rhino on the JVM, but I'm hoping for a leaner solution.
Has anyone heard of another, more rubyish perhaps, option ?
Edit : Reading the comments I'm starting to think ...
I've been writing a ruby programme that merges the content of two files.
For example if a torrent have been downloaded two times separately, it tries to merge their contents for the blocks which have been completed.
So, I've been looking for a method which modifies a stream only at the place required and saves only that block instead of...
Is it okay (conceptually) to run for loops in test methods?
I'd like to test a range of parameter values into a controller, to determine if the different inputs return the correct values.
test "logged in user - add something - 0 qty" do
@app = Factory.create(:app)
(0..5).each do |t|
@qty = t
login(:user)
ge...
I am trying to compile a java source file via a Ruby Script. However I am a bit puzzled by the following behavior
compile_results = `javac #{source_file}`
this fails to run with a 'No such file...' error. I popped up irb
irb(main):001:0> `javac -help`
Errno::ENOENT: No such file or directory - javac -help
from (irb):1:in ``'...
When I use the attr_accessible to specify which fields from my Model I will expose, is it true for script/console as well? I mean something that I didn't specify as attr_accessible won't be accessible as well through console ?
...
Hi there,
I've got a really simple xml doc (extracted from an html table), and a really simple Nokogiri script, but for some reason I can't get the text out of the xml nodes. I can get attributes, but not the text/content. Anyone have any idea what could be wrong with the following?
Here's the xml:
<?xml version="1.0" encoding="UTF-8"?...
I have learned the language itself as well as html/css/javascript. But with no database knowledge and (a bit)network knowledge. When I read the Pragmatic book on ROR, I found it confusing at the very beginning where they creates a project and setting up databases and models. Should I learn some database(and network knowledge)knowledge fi...
Hi,
I have been trying to wrap my head around this for a while now but have not been able to come up with a good solution. Here goes:
Given a number of sets:
set1: A, T
set2: C
set3: A, C, G
set4: T
set5: G
I want to generate all possible sequences from a list of sets. In this example the length of the sequence is 5, but it can be a...
Hi guys, just wondering the difference between the presence of the last comma in the array, if there is any at all
>> [1,2,3]
=> [1, 2, 3]
>> [1,2,3,]
=> [1, 2, 3]
The second array still works, no exception raised
Thanks
...
What's the meaning of an object's hash value? And in which case does two object has the same hash value?? Also it is said that Array|Hash can't be Hash keys, this has something to do with object's hash value, why?
...
Ok, I've asked a few related questions here and only ended up with more questions and I realized now it's because I don't have enough background info. So I'll make it more generic:
I need to make a simple web application. Static HTML/JQuery pages will send AJAX POST requests to some server side code, which will:
Read the POST variable...