Hi,
I am trying to find the intersection values between multiple arrays.
for example
code1 = [1,2,3]
code2 = [2,3,4]
code3 = [0,2,6]
So the result would be 2
I know in PHP you can do this with array_intersect
I wanted to be able to easily add additional array so I don't really want to use multiple loops
Any ideas ?
Thanks, Alex...
I run a Rails web app that generally has moderate traffic (100 requests/hour at most). However, I get a relatively high burst of traffic once every few weeks (50 requests/sec for 2 hours) at a time that I can anticipate. Over the next few months, I expect both the moderate and peak traffic to increase, but their relative magnitudes will ...
I have
<%= observe_field :tb_search,
:frequency=>0.5, :update=>'reports',
:url=>{
:action=>'filter_reports',
:only_path=>false,
:user=>@user.id},
:with=>"'search='+encodeURIComponent(value)" %>
but on the controller side, params[:user] is nil.
I did a
puts "NTHDEONUTHDOEDEUU#{params[:use...
Hi,
I've installed passenger (don't know if the installation is correct) onto apache (i'm just using a development macintosh running snow leopard).
the httpd.conf file has a VirtualHost setting like this
<VirtualHost *:80>
ServerName myapp
DocumentRoot /webapps/boom/public
<Directory /webapps/boom/public>
Allow from all
...
Lets imagine that I have a custom image upload for a particular record and I add two columns into the model.
thumbnail_url
thumbnail_path
Now lets imagine that I have a form with a :file field which is the uploaded file in multipart form. I would need to somehow have the model pickup the file within the given hash and then issue it ove...
I am using single table inheritance in StudentHours and TeacherHours, which have a parent Hours.
The model code is mostly in hour.rb, and very little in student_hour.rb and teacher_hour.rb
Now I have realized that most of the controller code is duplicate as well, so I've created a hours_controller to be the parent of students_controlle...
Hello,
I am having problems with my many to many relationships.
I have setup the appropriate connections, linking the join tables.
has_and_belongs_to_many :users, :join_table => "users_logins", :foreign_key => "login_id"
has_and_belongs_to_many ....
when I try to search using User.find(:all, :include => :login ...)
I get the resul...
I'am having a strange error, likely it is a server-side issue. My error callback is always triggered, even when the response status is 200!
Javascript //client
function save_pomodoro(){
j.ajax({
url: '/app/save_pomodoro',
dataType: 'json',
cache : false,
success: save_pomodoro_suc,
error: save_pomodoro_err,
...
I'm fairly new in the Ruby + Rails scene. Although I have a very strong understanding of design patterns, data structures and algorithms - there's a ton of "must have" plugins that I haven't had a chance to run into yet. There's things for migrations, resource controllers and a myriad of other plugins that make developing for these platf...
I can't figure out why ascend_by won't work for me. Here's a console readout
>> tapes = Tape.search(:timestamp_gte => "1278361923")
=> blah blah blah
>> tapes.length
=> 1436
>> tapes.ascend_by_timestamp
=> nil
I get the same behavior when I use descend_by and other columns.
ruby 1.8.7
Rails 2.3.8
searchlogic 2.4.19
...
I can't imagine it indexing per vote. It would strain the server innapropriately.
I mention this because I'm trying to do something similar on a project of mine, and can't figure out what the best way to index objects after they have been voted on.
I am using Sunspot-Solr.
...
I am trying to add a string variable as a child of a node. The code that I'm using looks like this
$(this).parentNode.parentNode.insertBefore('content',$(this).parentNode)
I believe that this is correct syntax, but I keep receiving NOT_FOUND_ERR: DOM Exception 8. Does anyone have any pointers?
...
I am receiving the following error, when running cucumber:
undefined method `overall_rating_id=' for #<OverallVote:0x102f1c4a0> (NoMethodError)
Relevant classes are:
class OverallVote < Vote
belongs_to :overall_rating
attr_accessible :overall_rating_id
end
class OverallRating < Rating
has_many :overall_votes
end
I thought th...
Hello
I get this error I18n::MissingInterpolationArgument when running this code
<%= l Date.today, :format => :short %>
It has worked before, but now, at Ubuntu, with Rails 2.3.5 and Ruby 1.8.7 (2010-06-23 patchlevel 299) [i686-linux] it doesn't work anymore ...
Anyone to help?
...
Hey,
I am trying to create a intersection statement using a foreach loop
for example
cand[0][1,2,5]
cand[1][2,5,6]
@result = cand[0] & cand[1]
with a for each
intersec = Array.new
cand.each do |c|
intersec = intersec & c
end
@result = intersec
I get an empty array
Thanks
Alex
...
I have a nice RESTful controller in my Rails application that uses responds_to to distinguish between requests for HTML and CSV requests, serving the HTML if one uses the URL normally, and the CSV if one adds ".csv" to the end of the URL.
In my view layer ERB file, I want to have a link to the CSV. I could just get the URL for the appro...
The project: Imagine a card collector wants to create a database for all his card collections , they collect every type of trading card available. Each trading card has a different set of information (stats) depending on it's type but there could be an infinite number of categories of trading cards. So my questions is, is it better to cr...
I'm actually just copying an old question from railsforum as he asked it back in May '09 and the only reply is the authors own inelegant fix. I wondered if anybody knows of a better way? Otherwise I'm going to end up using javascript to move the hidden field about as he has.
Here's the original question:
Hi there!
Grateful ...
Where is logout_path defined in the authlogic library for rails?
More generally, where are any of these paths defined? I'm a bit mystified how rails 'knows' where these are because I searched my entire project and didn't see any matches, including the vendor folder, which means that they're either packaged in a gem (maybe the authlogic...
I'm trying to have a rails model observe another object (which acts as a subject). I saw that there is an update method (which has different semantics) in ActiveRecord::Base, but in order to use the Observable module, I need to implement an update method in my model so that I can be notified of changes to the subject.
Any thoughts on h...