Hi there, the photo display sript is below:
<% if user.image %>
<%= image_tag user.image.url('100x20') %>
<% end %>
How can I only showing the right side of the photo by 20 x 20 on the web. it mean cut off the 80% on the left show only 20% of the whole picture.
Many thanks!
...
Hi All,
Not sure how to frame this one, so here goes...
I have a need to develop an application which allows my boss to post a series of questions that will be answered by various consultants around the world, each question will have a time limit in which it can be answered e.g. 3 minutes.
Here is the problem, the users answering the ...
I've been looking around for libraries that will allow me to get a multidimensional hash of a given XHTML string.
XHTML:
<div class="class-1 class-2" id="my-id">
<div class="classy">
</div>
</div>
Expected Hash:
hash = {
:div => {
:class => ['class-1', 'class-2'],
:id => ['my-id'],
:children => {
:div => {
:c...
Text Area helper , how i set the maximum length of string to 100.
Is there is any max length attribute in text-area helper in ROR.
Code will help me.Thanks
...
Not sure on my Ruby syntax here.
I want to define a method that I can call like this: client.invoices.average_turnaround. So my average_turnaround method needs to work with a collection of ActiveRecord objects.
Here's my code thus far:
class Invoice < ActiveRecord::Base
...
def self.average_turnaround
return self.map(&:turnaro...
Using the tutorial "Find Stuff (quick and Dirty)" in "Advance Rails Recipes", I can find stuff in the development environment but not in the production environment.
NoMethodError: undefined method `searchable_by'
I have this code in "lib/searchable.rb"
module Searchable
def searchable_by(*_column_names)
@search_columns = []
...
For my first question here I would like to ask you how you'd do the following in Ruby.
I have a hash with the following aspect
variables["foo"] = [1,2,3]
variables["bar"] = [4,5,6,7]
variables[...] = ...
Update: this hash will have an arbitrary number of key => values pairs.
So it represents parameters and their possible values. I w...
Im currently trying to integrate with a third party API using active resource.
Ive completed a large amount of the work but am struggling with a single nested resource.
/company/:company_id/users/:id
I can retrieve the users from the company using
API::Company.find(124343).users
but any subsequent changes to a user will not save.
...
I have a simple constant called "subjects" in my model Inquire.rb and I like to know if there is a simple way to use the position in the Ruby array rather than making a hash from it with ids or some more complicated array.
Can I do this?
i.e. instead of to_s as it currently does for the value in the select, I would want an integer indi...
When sent a message, a Ruby object searches to see whether it has a method by that name to respond with. Its method lookup searches in the following order, and uses the first method it finds.
Singleton methods defined on itself
Methods defined in its class
Any modules mixed into its class, in reverse order of inclusion (only the earlie...
Gem dependency version can be specified with prefixes =, <, >, <=, >= and ~>. I understand all except last one, what does ~> mean?
...
Hi,
I'm using ffmpeg to transcode a rtmp-stream and re-stream it with ffmpeg.
I have 2 problems:
how can I check if the remote rtmp-stream is running and then start ffmpeg
sometimes ffmpeg brake up transcoding and it must be restartet automatically
Any hints to do this with a shell-script, ruby or php?
...
What is the correct way to route your request through Sinatra so that it serves up the file with no processing? I'm looking for the most common way people do this in the Sinatra framework? I normally place all of my static content in a "content" path.
examples:
/content/css
/content/img
/content/js
How can I use a wildcard to serve...
{"Journal"=>[[4, -785.0],
[13, -21.9165000915527],
[14, -213.008995056152],
[15, -50.074499130249]]}
How can you to iterate this hash in Ruby, and how would you to separate out keys & values?
...
Hi,
I am pretty sure that Ruby has these (equivalents for __call, _get and _set), because otherwise how find_by would work in Rails? Maybe someone could give a quick example of how to define methods that act same as find_by?
Thanks
...
When working with activerecord I notice that while constructing associations, the reciprocal association is provided automatically only if the reciprocal model has already been saved. If it has not yet been saved, this reciprocal association must be defined manually. I am wondering if this is intentional or a bug, since the only differ...
Hi All,
Is there any Ruby library available to format the HTML source. By formatting I mean removing the extra spacing, apply proper indentation etc.
I am already using Hpricot for parsing HTML. It would be nice if Hpricot could do this job. But I am not stick with Hpricot for the formatting stuff.
Thanks,
Imran
...
I have installed RubyMine on Mac but my development environment for Ruby and Rails is on an Ubuntu VPS.
When I run IRB in RubyMine, I assume it is using my Mac environment's IRB?
Cause I have installed rvm, bundler, gems etc in my Ubuntu VPS.
Is it possible to create an application in my Ubuntu VPS and use that environment rather than...
So everything works. But if a user has firebug's console open, they'll see a bug. :D
When my AJAX is sent :
$(".remove_qf").live("click", function(){
$.ajax({type: "POST", url: $(this).attr("href"), data: { '_method': 'delete' }, dataType: "script"});
return false;
})
And my controller fires it :
def destroy
@quick_fact = @org...
I'm new to Ruby (experienced with Python, C++ and C). I need to create a class that is only to be used by other classes and methods in a module. In Python, I'd just call it __classname. I'd use an empty typedef in C++. How do I do this in Ruby (or am I barking up the wrong tree and not doing this the "Ruby way"?)
...