named scoped NOT IN, how to?
how can I write a NOT IN in named scope syntax? For example, User :has_many Photos, how can I define: User.has_no_photo and returns all users who are not in the Photo model? thanks! ...
how can I write a NOT IN in named scope syntax? For example, User :has_many Photos, how can I define: User.has_no_photo and returns all users who are not in the Photo model? thanks! ...
I'm trying to unpack all the system gems to end up with a standalone Rails directory including all the rails gems and all the system gems. I'm starting with a bare rails setup; just did a jruby -S rails and a 'generate jdbc'. I then add a config.gem 'jdbc-mysql' to environment.rb and do the jruby -S rake gems:unpack:dependencies. Afte...
Our app provides an API that people can use to submit URLs like this: curl -X POST http://app.local/resource -d'url=http://news.google.com/newshl=en&q=obama&um=1&ie=UTF-8&output=rss' Unfortunately, it seems that Rails messes up with this param. Any idea on how to fix this? See the log below : Processing ApplicationC...
I am trying to display a waiting spinnger, while uploading a file. I am able to show the spinner, and to do the upload, when doing it individually. My problem is how to combine these two. The Jquery Javascript looks like: <% javascript_tag do %> function showLoading() { $("#loading").show(); } function hideLoading() { $("#loading")...
I have over time, changed the size for thumbs of the class Deal. Through these changes, users were uploading to the site, so there are few people who have different sized thumbs. I wanted to reprocress or refresh these, so I went to into my root and typed: $> rake paperclip:refresh class=Deal Did nothing for the thumb sizes.. Then I i...
When I run cucumber from my Ubuntu server I don't get details on why the scenario is failing. For example here is what I get: ..... cucumber features/messaging.feature:6 # Scenario: Joe can view his inbox cucumber features/messaging.feature:14 # Scenario: Joe can send a message cucumber features/messaging.feature:26 # Scenario: Joe can ...
I've setup some models in the table inheritance fashion and everything seems to be all fine and dandy. But, when I use a collection select field to select values from one of the models it saves it but it saves the ID of the data and not the actual value of the data. So when I try to display the value on the show view it just shows the co...
New to Rails and trying to get my head around when/why to use :symbols, @ivars , "strings" within the framework. I think I understand the differences between them conceptually only one :symbol instance per project one @ivar per instance multiple "strings" - as they are created whenever referenced (?) Feel free to correct me! The ma...
I am trying to remove all 's in my model with the following method : def about_us_sans_spaces self.about_us = replace(self.about_us, " ", " ") end Except! it turns out 'replace' isn't a method in rails. How would you remove the 's? Mind you, I have already tried sanitized, simple_format. My view looks like this rig...
I'm in the console, looking at someone else's app. I come across the following: >> p.location => [#<Tag id: 2, name: "projects">] Why do I see this result, which seems to be the object name, and how do I access the actual attribute name, "projects"? >> p.location.name => "Tag" Thank you very much! ...
it was very weird that yesterday, I was do an integration test in Rails and assert_equal array_of_obj1, array_of_obj2 # obj1 from db, obj2 created in test and it failed. The values shown inside the array and objects were identical. If I change the test to assert array_of_obj1 == array_of_obj2 Then it will pass. But today, th...
I have a model called a voip_phone that has a an attribute schedule which is a string that keeps track of which people are using the phone at what time. Here's an example of a schedule: "mon{}sun{}sat{}tue{13,08:45,15:15;}wed{13,09:00,17:30;}thu{}fri{}" Here is the model code that won't work: def add_shift(days, person_id, time_f...
Hi, I have a pdf file attachment saved in the cloud. The file is attached using attachment_fu. All I do to display it in the view is: <%= image_tag @model.pdf_attachment.public_filename %> When I load the page with this code in the browser, it does what I want: it displays the attached pdf file. But only on Mac. On Windows, browse...
Is it possible to configure jrails so that it only replaces the ruby on rails helper methods for some parts of the site? I am currently in a project where we are doing a staggered migration to jQuery so the site wide choice is not an option in this case. ...
Hi, I have a site with several pages for each company and I want to show how their page is performing in terms of number of people coming to this profile. We have already made sure that bots are excluded. Currently, we are recording each hit in a DB with either insert (for the first request in a day to a profile) or update (for the f...
I have been an evil coder - working like crazy to get a ROR demo operational and ignoring RSpec. Does anyone have any helpful (aka; friendly) advice on using RSpec to get the current implementation under BDD control? Especially pitfalls to avoid. Many thanks. ...
I've just installed this plugin, created the migrations, added everything I needed to make it work(I didn't install ImageMagick yet). The problem is when I get the upload control parameter to save it in my controller, I get something like this: #<File:C:\Users\Brian\AppData\Local\Temp\RackMultipart.2560.6677> instead of a simple stri...
I found mysql2 gem. It works fine with ruby 1.9 and utf8 encoding (as opposed to mysql gem). But I have doubts. Does somebody use this gem in production? What about the performance test? Is it faster than mysql gem? Is it stable? ...
I have a really simple question, is it possible to update a table with new values using just one update statement. Say for example I have a table with author, title, date, popularity. Now I got some new data which has author name, title corresponding new popularity. How do I update the table now in one statement. Note that author and ti...
I see lots of : map.root :controller => "home" Its I know simple, but what does home point to? A file? A controller? How/where does it gets its magic? ...