I have looked through the Ruby on Rails guides and I can't seem to figure out how to prevent someone from deleting a Parent record if it has Children. For example. If my database has CUSTOMERS and each customer can have multiple ORDERS, I want to prevent someone from deleting a customer if it has any orders in the database. They shoul...
I have a basic search page that replaces html in a div with the search results.
Clicking on one of the search results brings up a detail page. And I have a link on that detail page that says "Go back to search results".
My problem is that it just generates a link to the root_url. Is there a way I can generate a valid back link to thos...
I have been using the devise gem for rails and I have facebook login system working. My problem is that there is so much going on in the background that I find it difficult to customize this. For example how do I change the path to the page the user is redirects to after the first time facevbook login, not the usual facebook login.
It a...
What i would like to do is when a user clicks an image of a horse that a checkbox is then set to true or false.
I have an array of horses and each horse has a checkbox.
The biggest problem I have is setting the ID of my checkbox element. I tried sth like. http://stackoverflow.com/questions/2360465/use-custom-id-for-check-box-tag-in-rai...
I am using:
Event.observe(window, 'load', function() {
$$('li').invoke('observe', 'mouseover', function(event) {
this.children[0].toggle();
});
$$('li').invoke('observe', 'mouseout', function(event) {
document.children[0].toggle();
});
});
<ul>
<li>
<div style="display:hidden;">Hidden Div</div>
<div>More...
Need some help refactoring this if/else block that builds the conditions for a find query.
if params[:status] && params[:carrier]
conditions = ["actual_delivery IS NOT NULL AND actual_delivery > scheduled_delivery AND status_id = ? AND carrier_id = ?", status.id, carrier.id]
elsif params[:status]
conditions = ["actual_delivery IS NO...
I have some thinking-sphinx tests that I need to turn off transactions for to prevent mysql locks, but in doing so I break a lot of other tests previously written, so I need to be able to toggle the setting.
I have found similar questions regarding rspec, but none for Test::Unit.
I have tried self.use_transactional_fixtures = false whi...
I updated from 2.3.3 to 2.3.5 for the string to array bug, and now when I try to call Model.image.reprocess! I get the following error. Is this something in my code or something in paperclip? Or maybe in the image I'm uploading?
"\xFF" from ASCII-8BIT to UTF-8
/home/brian/.rvm/gems/ruby-1.9.2-p0@sp/gems/paperclip-2.3.5/lib/paperclip/sto...
I'm working with Ruby on Rails 2.3.8 and I want users to login before accesing any content from the website.
I've written the following in the application_controller
before_filter :login_required
When the app starts, I'm getting an error in the browser (not even from the application itself) saying it failed to redirect the page. And ...
Hi,
I quickly ran into problems when trying to create an ActiveRecord instance that overrode initialize like this:
class Email < ActiveRecord::Base
belongs_to :lead
def initialize(email = nil)
self.email = email unless email.nil?
end
end
I found this post which cleared up why it is happening.
Is there anyway that I can avo...
Previously I ordered my posts as this :
@posts = Post.find(:all, :order => "created_at DESC")
But now I want to replace created_at with a custom method I wrote in the Post model that gives a number as its result.
My guess:
@posts = Post.find(:all, :order => "custom_method DESC")
which fails..
...
Let's say I have a string like so:
"Lorem ipsum de color [post]57[/post]
sit amet [post]103[/post] desectator."
I want to find all occurrences of [post]*[/post] and replace it with the title of the post represented by the number. I'd end up with something like so:
"Lorem ipsum de color Angry Turtle sit
amet Fuzzy Rabit dese...
I am running ROR 3.0.1 with Ruby 1.9.2p0 on a Mac Mini with Snow Leopard 10.6.4.
when I run rake db:migrate I get the following error
/usr/local/lib/ruby/1.9.1/rubygems.rb:340:in bin_path': can't find executable rake for rake-0.8.7 (Gem::Exception)
from /usr/local/bin/rake:19:in'
I have uninstalled and reinstalled rake but I still ge...
Is there a command that tells you the other gems that a gem depends on?
Also, is there a way to auto install the gem's dependencies?
...
I looked through a number of posts with similar titles but have not found an answer.
In my application I want to allow editing Active records from an index view. This view uses link_to_remote for each row. When user presses the link the row should be replaced with a form that user may submit via Ajax.
Table is displayed by sending a ...
I did a bunch of gutting to my default controllers and now I can't get my user_id to populate on create.
I was curious how that gets populated. If you're interested, take a look at my routes, and model assocations, and then at then end I'll show you the resulting params..The end result is no user_id being added.
routes
resources :user...
I'm working on a pretty large data migration project which involves moving data between servers and different active record schemas. The whole migration literally takes days.
How can I implement a caching solution where my Ruby migration code when it calls the Active Record save method writes to a cache (which then updates the MySQL da...
Short version: Where should I store environment-specific IDs? ENV['some-variable']? Somewhere else?
Long version:
Let's say I have a model called Books and a book has a Category. (For the sake of this question, let's say a book only has one category.)
class Book < ActiveRecord::Base
belongs_to :category
end
class Category < Acti...
Hello, I'm using rails 3 and am trying to use the in_place_editing plugin:
http://github.com/wanglian/in_place_editing
# Controller
class BlogController < ApplicationController
in_place_edit_for :post, :title
end
# View
<%= in_place_editor_field :post, 'title' %>
However I'm getting the error: id for nil, which would m...
Hi All,
Once again I come to the best for my pedestrian question.
I'm building a small web app that would be vastly improved by the ability to recognize app icons. I've searched all over but haven't found anything that suits my needs.
Basic Experience:
User uploads a screenshot
We extract icons
We return the name of the correspondin...