I am using attachment_fu for file uploading... it saves the files to asset/0000/0001... something like this... i want to upload a file to a specific folder defined by a user... for example images to a specific folder... just like galleries...
how will i achieve this... help me out here...
thankx
take care..
...
class_name = 'Question'
instance = which_method(class_name)
Which method I should use?
...
I've been at this for a couple of day, and am having no luck at all. Despite reading over these two posts, I can't seem to rewrite this little python script I did up in ruby.
clean_link = link['href'].replace(' ', '%20')
mp3file = urllib2.urlopen(clean_link)
output = open('temp.mp3','wb')
output.write(mp3file.read(2000))
output.close()...
I'm using Hpricot to parse an html page, but need to get the computed styles for each element. For example, if I have an h1 Hpricot element and the external CSS for the page has a background-image defined for h1's, how can I find out what the background-image is?
...
In Ruby, how can I traverse an arbitrary document retrieved from a collection using something like mongomapper? Let's say the document looks something like this:
mydocs =
[{"title":"my title",
"description":"hello world",
"comments":[{"user":"me","text":"this"},{"user":"him","text":"that"}]
},
{.....}
]
...
I tried
class X begin end
and
class X {}
neight correct. What is the right code?
...
requrie 'yaml'
hash = {:title=>'abc'}
hash.to_yaml
will output:
---
title: abc
Is there any method to force the title to be a binary, like:
---
title: !binary|
5Lit5pa
UPDATE
I'm asking this because I want to dump the data from database to yml files. But the text in the database, contains English and non-English text, and bot...
I'm find such a gem a whole day, but not find a good one. I want to write one, but I'm not able to do it.
The data in my database may be English text, which will be dump to a yml file with plain text. And some are non-English text, which will be binary type.
And both of them may have such code:
<% xxx %>
When I use rake db:fixtures:...
So for example, if I give like this
map.root :controller => "pages", :action => 'show', :slug => "**homepage**"
map.connect '*slug', :controller => 'pages', :action => 'show'
what will happen?
...
HI
whats the difference between these two ruby if statements when we put a then at the end of the if statement?
if(val == "hi") then
something.meth("hello")
else
something.meth("right")
end
and
if(val == "hi")
something.meth("hello")
else
something.meth("right")
end
thank you
...
Hi,
Did anyone try scripting/Automating an Appstore app submission?
It will be amazing if we can save all the necessary info in a plist or a server, Click on one button to generate and Upload the App to iTunes connect.
This will be very useful if we have to develop template based Apps.
Any expert opinions/comments/samples?
...
In my application I have 2 classes like this:
class City < ActiveRecord::Base
has_many :events
end
class Event < ActiveRecord::Base
belongs_to :city
attr_accessible :title, :city_id
end
If I create city object:
city = City.create!(:name => 'My city')
and then pass parameters to create event like this:
event = Event.create!...
I'm looking to write an app for the shell, *nix mostly. And I'm currently in love with Ruby, especially the 'rails way'.
So if there was a framework that applied rails like concepts to the commandline in ruby then that would be really fantastic.
I'v allready looked into SimpleCommand and Hirb, nothing quite what I was looking for.
To ...
How to produce delay in ruby?
I used sleep statement but it didn't give me what I want.
puts "amit"
sleep(10)
puts "scj"
I want it to first print amit, then a delay of 10 seconds, then print scj.
But in above case what happens is it will pause for 10 seconds and then it will print amit and scj together. I don't want that.
I hope yo...
Is there any way, to track dynamically which classes or modules are included in required files.
a short example:
#my_module.rb
module MyCustomModule
def foo
end
end
#custom.rb
require 'my_module.rb'
#is here any way to track which modules are in the required 'my_module.rb'
#without parsing the file or having some naming conventio...
hi all
I am pulling emails into my ruby on rails web app and displaying them from users to see and reply etc within my app.
Problem is the emails css when displaying the email effects my sites css and visa versa.
Any one know the best solutition to the problem ?
Can use an iframe i suppost but dont think secure ?
cheers
Rick
...
Possible Duplicate:
how to produce delay in ruby
how to produce delay in ruby i used sleep staement but it did nt give what i want
Actully
puts "amit"
sleep(10)
puts "scj"
i want first it print amit than a delay 10 sec than print scj but in above case what happens is it execution paused for 10 sec then it print
ami...
I'm new to sunspot and rails 3, so I followed this little tuto:
http://github.com/exempla/sunspot
But there is not a lot of details, and the official github of outoftime/sunspot do not speak much about the rails 3 version.
ex: How can I do a rake sunspot:reindex
So if anyone know where I can find some good rdoc for the rails 3 versio...
rubydoc.org has the core documentation for Ruby 1.8.x and Ruby 1.9.1, and for the 1.8.x standard library. But it doesn't document the 1.9.1 standard library, and nor does anywhere else I can find online (though Google shows other people looking for it). Is there somewhere else to look, or are folks generating their own 1.9.1 library docu...
I have a rails app (2.3.5) running on a VPS with 4 cores @ 2 GHz and 4GB memory. I am running nginx (0.7.61) and phusion passenger(2.2.14) on Ruby Enterprise (1.8.7-2010.01) with the max pool size set at 30. My problem is that it seems as if every ruby process that is executing a rails request runs at near 100% cpu. If I run TOP they ...