A friend of mine asked me if I was aware of Ruby on Rails ... and frankly I have heard a lot about it but know practically nothing about it. Any help will be much appreciated.
I'm working on integrating ruby with ldap. And it's working fine.
Created test.com in ldap and I can bind with it successfully.
Then I created a new organizational unit company. Under company there are some users
Now I want to bind with the users(authentication) under company organizational unit.
I can access the user using Filter.eq
But I want to bind with the users.
Suggestions plz..
Can't seem to find how to check if an object is a boolean easily. Is there something like this in Ruby?
true.is_a?(Boolean)
false.is_a?(Boolean)
Right now I'm doing this and would like to shorten it:
some_var = rand(1) == 1 ? true : false
(some_var.is_a?(TrueClass) || some_var.is_a?(FalseClass))
My company has data messages (json) stored in gzipped files on Amazon S3. I want to use Ruby to iterate through the files and do some analytics. I started to use the 'aws/s3' gem, and get get each file as an object:
#<AWS::S3::S3Object:0x4xxx4760 '/my.company.archive/data/msg/20131030093336.json.gz'>
But once I have this object, I do not know how to unzip it or even access the data inside of it.
Hello all, I have been trying to post blogs to Blogger via the API provided for posting but the problem I have is how to write the ruby code for the http post that will be able to carry the texts and make the post. In the API, it is stated that one has to First, create an XML representation of the post to publish.
Please can someone help me with a suggestion. This is the API that was provided: "http://www.blogger.com/feeds/blogID/posts/default"
ruby on rails ferret search:.only 10 records are getting from table.For pagination i did it ,but only 10 records are getting even though there exists more records satisfying the search condition.if any of you know how to solve this,please reply. no limit is givenf it is not a ferret search all records are getting from table , and pagination is working
the code is:
@search_sd_ticket_result=ServiceDeskTicket.find_with_ferret(params[:sd_ticket][:servicedeskticket]).paginate :per_page =5, :page=params[:page]
The post office actually publishes a list of commonly used street suffixes in addresses:
http://www.usps.com/ncsc/lookups/abbr_suffix.txt
I want to take this list and make a ruby function that takes a string, takes the last word ("183 main strt".split[' '].last) and if it matches any of the commonly used street suffixes ("strt"), replace it with the official Postal Service Standard Suffix ("st").
Is there a better way to approach this than a massive str.sub.sub.sub.sub.sub?
hi,
anyone know how to create a suggestion box in ruby on rails? all the materials i found so far are about observe some text field and update some list in other , not related to suggestion box...
Thanks!
How do I include the 'autofocus' attribute on an HTML5 form using the text_field form helper in ruby?
e.g. <%= f.text_field :email %
Where does autofocus go?
Thanks
I want to install a ruby gem which tries to build a native extension. The gem in this case is nokogiri. If I do gem install nokogiri, the native extension dynamically links against libxml, libxslt libs. I want to statically link against those libs. How should I go about this?
Hi guy,
In ruby ActiveRecord doesn't provide dynamic binding for update and insert sqls, of course i can use raw sql, but that need maintain connection, so i want to know if there is simpler way to escape update or insert sql before executing like code below:
ActiveRecord::Base.connection.insert(sql)
i think i can write code by gsub, but i know if there has been a ready method to do it.
thank you very much, and Merry Christmas for you all.
for instance in python it is possible to assign a method to a variable:
class MyClass
def myMethod(self):
return "Hi"
x = MyClass()
method = x.myMethod
print method() # prints Hi
I know this should be possible in Ruby, but I don't know what's the syntax.
Are there any logging frameworks in ruby that allow you to log a specific event type only once?
logger = IdealLogger.new
logger.log(:happy_path, "We reached the happy path") # => logs this message
logger.log(:happy_path, "We reached the happy path yet again") # => Doesn't log this
logger.log(:sad_path, "We've encountered a sad path!") # => logs this message
Also, is there a term for the concept of logging a certain event type only once?
Hi,
I write a little ruby script, which sends me an email when a new commit added to our svn.
I get the log with this code:
log = `/usr/bin/svnlook log #{ARGV[0]}`
When I run my script from bash I get good encoded character in the email, but when I try it and create a new commit I get wrong hungarian characters.
I commited this:
tes
oéá
I get this in the email:
Log: tes
?\197?\145?\195?\169?\195?\161
How can I solve this issue?
Is there a better way to write this Expando class? The way it is written does not work.
I'm using Ruby 1.8.7
starting code quoted from https://gist.github.com/300462/3fdf51800768f2c7089a53726384350c890bc7c3
class Expando
def method_missing(method_id, *arguments)
if match = method_id.id2name.match(/(\w*)(\s*)(=)(\s*)(\.*)/)
puts match[1].to_sym # think this was supposed to be commented
self.class.class_eval{ attr_accessor match[1].to_sym }
instance_variable_set("#{match[1]}", match[5])
else
super.method_missing(method_id, *arguments)
end
end
end
person = Expando.new
person.name = "Michael"
person.surname = "Erasmus"
person.age = 29
Is this a ruby bug?
target_url_to_edit = target_url
if target_url_to_edit.include?("http://")
target_url_to_edit["http://"] = ""
end
logger.debug "target url is now #{target_url}"
This returns target_url without http://
In a simple Ruby example, I'm getting an error that does not occur in irb.
name = "Joe"
def say_hi
"\"Hi there!\" said #{self}"
end
response = name.say_hi
puts response
This code should return, "Hi there!" said Joe.
It works perfectly fine in irb. However, when I attempt to put the same code in a file and run the file, I get this error:
say_hi.rb:8:in `<main>': private method `say_hi' called for "Joe":String (NoMethodError)
Any suggestion about why this happens?
So I know in ruby that x.nil? will test if x is null.
What is the simplest way to test if x equals ' ', or ' ', or ' ', etc?
Basically, I'm wondering what the best way to test if a variable is all whitespace?
How to create a Qt GUI applications with the ability to access it from the ruby script.
Example:
require 'myQt'
myapp=myQt.new
myapp.startQtGuiApp
myapp.setValue('TextField1',45)
value=myapp.getValue('TextField2')
I want to have a "delete user" link in a normal Activerecord table, but I can't figure out how to wrangle the inline ruby in haml.
I have this:
%tbody
- @users.each do |user|
%tr
%td= user.name
%td= user.login
%td
%a
%img{:src => '../images/delete.png', :title => 'Delete user'}
How do I make the
- user.destroy
be a clickable link in Haml?
Is there an elegant way to check which port you deployed a ruby on rails application using mongrel? I could not find a directive (i.e. such as #{RAILS_ROOT} which contains the root directory of the application) that I can use to perform a check. I need this to do a check since I am deploying the same application on different ports and I need the app to do different things according to the port that is being accessed.
Any help would be appreciated,
Thanks