My googlefu sucks and was unable to find information on this.
Basically I want to have a instance variable that is visible only within the scope of a class/module but is also immutable.
I am new to Ruby and apologize if this question doesn't make much sense.
...
This happens in Ruby on Rails's View, where there is a hash for another partial. This hash has about 20 key/value pairs.
There is (in HAML)
- if (some_conditon)
= render :partial => 'some_name', :locals => a_hash.merge({ :extra => true })
- else
-# a lot more processing, including concatenating the partials and return as json
- ...
Hello there,
I need to execute a rake task in a windows machine and unfortunately to do so I have to open a shell. How can I close it once the task has been completed?
system('start rake db:MyTask')
Thanks,.
...
I have a bunch of different controllers that all deal with the same basic model. For example...
FoobarController
FoobarShareController
FoobarTakeController
FoobarToolsController
FoobarVerifyController
They all do various things to the foobar model and I kind of wanted a better way to organize them along with other things that deal w...
Is there an easy way to rename a controller? The only way I know of is to either do it by hand or generate a new controller move the code over and destroy the old one. Seems like there has to be a programmatic way to do this.
...
How can I get a lazy array in Ruby? E.g., in Haskell, I can talk about [1..], which is an infinite list, lazily generated as needed. I can also do things like iterate (+2) 0, which applies whatever function I give it to generate a lazy list. In this case, it would give me all even numbers. Anyway, I'm sure I can do such things in Ruby, b...
I'm using Ruby to check the position of videos I'm playing in Quicktime via Scripting Bridge.
At the moment I'm just checking the position like so every n seconds:
require 'osx/cocoa'
include OSX
OSX.require_framework 'ScriptingBridge'
app = SBApplication.applicationWithBundleIdentifier_("com.apple.QuickTimePlayerX")
while true
ap...
I've got a simple model object:
class UserRating
include MongoMapper::EmbeddedDocument
key :idea_id, ObjectId
key :rating, Integer
end
I'm trying to set an Idea_Id on this object with:
user_rating.idea_id = ObjectId.new
This throws: "illegal ObjectID format"
This sure seems like simple code... The only oddity I am noticing ...
I would like to know whether I can get source code a method on the fly, and whether I can get which file is this method in.
like
A.new.method(:a).SOURCE_CODE
A.new.method(:a).FILE
...
Hello,
I was hoping someone could suggest some best practices for configuring Rails applications using a database (i.e. persisting configuration settings to a database rather than a flat file). My reasoning for this is that I have an application that will run on multiple servers and there are some configuration settings that are fairly ...
Are there any OData provider SDKs for Ruby or Java?
...
Hi, I want to print a key from a given hash key
but can't find simple solution
myhash = Hash.new
myhash["a"] = "bar"
# not working
myhash.fetch("a"){|k| puts k }
# working, but ugly
if myhash.has_key("a")?
puts "a"
end
Any other way?
tnx
...
What would be the best way to go about giving users the ability to share a private link that enables anyone who clicks it to view a certain page/document/item that have privacy restrictions in place?
In my case:
A User creates events which are limited to certain groups of relationships in the database (namely: friends, friends of frien...
Hello,
I am playing around with ruby and making my first desktop app. I have used 2 gems for my app and to make my "application" portable, I need to freeze those 2 gems and make my project refer to those gems from its project folder.
I know many ways to do it on Rails, but how to do it manually in Ruby?
Note: I am using jeweler using ...
I'm currently using acts_as_taggable_on_steroids on Rails 2.3.8. After configuring the plugin, when i try to destroy a post with a tag, it gives me this error:
undefined method `destroy_unused' for Tag(id: integer, name: string):Class
Do i have to redefin a destroy method in my Posts controller?
I'm stumped, any help would be apprecia...
This is a C# code:
byte[] pb = System.Text.Encoding.UTF8.GetBytes(policy.ToString());
// Encode those UTF-8 bytes using Base64
string policyB = Convert.ToBase64String(pb);
// Sign the policy with your Secret Key using HMAC SHA-1.
System.Security.Cryptography.HMACSHA1 hmac = new System.Security.Cryptography.HMACSHA1();
hmac.Key = Syste...
I have a problem with Ruby's openssl library.
Here is what I do:
In my Rails application, I start the "./script/console", then type:
>>OpenSSL::HMAC.hexdigest('sha256','','')
gives me this error:
TypeError: wrong argument (String)! (Expected kind of OpenSSL::Digest::Digest)
from (irb):15:in `hexdigest'
from (ir...
Hi guys,
Our website allow video upload; clients were able to download videos from youtube, upload them on our website, then FLVTool2 (ruby) is used to process the videos.
This tool was working for couple of years, but now it gives me some errors due to the new youtube encoding.
the error I have is
ERROR: EOFError
ERROR: /usr/lib/ru...
The content in the view is not being displayed. Only the attachment is being sent. Help would be appreciated!
def send
@subject = "Status of PIS App"
@recipients = "[email protected]"
@from = APP_CONFIG[:email]
@sent_on = Time.now
#@content_type = "text/html"
content_type = "multipart/alternative"
attachment :filename => "Report.ht...
Is there a widget or a gem which implements this feature?
It works only in Chrome and Firefox but it is very cool and no plugins are needed
http://gmailblog.blogspot.com/2010/04/drag-and-drop-attachments-onto-messages.html
Or which would be the best practises to implement it?
...