I have a small rails app. I want to put audit trail in it. Basically when a new user is added. it will insert a row in AuditTrailUsers table with the new user_id created and logged in users' user_id.
I am thinking about using rails callback before_save for this. However, I am not sure if that will work.
Imagine I have model/Users.rb ...
Help me understand this; I'm learning Sinatra (and Rails for that matter, er, and Ruby).
Say I'm doing a search app. The search form is laid out in one div, and the results will be laid out in another. The search form is rendered into the div by a previous view (maybe from a login form).
I want to process the form params, perform the...
I have a fairly large model and I want to retrieve only a select set of fields for each record in order to keep the JSON string I am building small.
Using :select with find works great but my key goal is to use conditional logic with an associated model. Is the only way to do this really with a lamda in a named scope? I'm dreading that ...
Guys & gals,
What's a best-in-class Rails option for importing/exporting spreadsheet data? Preferably w/o requiring an intermediate conversion to/from .CSV?
I see several options, but no clear preference (thus far). Ideas?
Thanks & regards,
Brian Piercy
...
I'm serving ads using OpenX within Rails. To correctly use the OpenX full page invocation you need to set Oa_zones[] array, otherwise all available ads are requested (but will never be used).
These are the necessary pieces:
Build an array of zones. Ideally zones could be added in any partial, so working with this array needs to be a...
Hi,
I use Rails 3.0.0 Beta
following an action, my RJS view returns JavaScript, but the code is not executed
In Firebug I see in my response
$('polaroids').insert("<li>\n <a title=\"4204497503_a0c43c561d.jpg\" href=\"#\">\n <img alt=\"4204497503_a0c43c561d.jpg\" src=\"/system/photos/279/original/4204497503_a0c43c561d.jpg?12688573...
We have an application with a app/model that references another model stored in a plugin.
When the app/model level is reloaded on the second and further requests and that relies on our model in vendor/plugins/... (which stays loaded) it fails (can't dup nil class).
We've tried setting config.reload_plugins = true in the development.rb...
In every benchmark that I found on the web it seems that Ruby is slow, much slower than Java. The Ruby folks just state that it doesn't matter. Could you give me any example that the speed of Ruby on Rails (and the Ruby itself) really doesn't matter?
...
Hi,
I'm trying to stub a third party service that my metal talks to. It seems rspec mocks/stubs don't extend all the way to the Metal.
When I call stubbed methods on objects, it calls the original one and not the stubbed one.
Any idea of how I can have rSpec doubles extend all the way to the metal?
Thanks.
-Nash
...
Short and sweet,
Is it ok to use (current version) Ruby 1.9.1 with Rails 2.3.5?
Thanks for any additional info!
...
i expect a long array containing integers
[3,7,7,7,7,1....]
but the overall distribution should be skewed and normal.
using random() generates a uniform distribution.....
...
Hi guys,
I'm trying to find out where this function comes from. Any one have any clue? It's used by this:
http://github.com/fluidtickets/facebooker-authlogic-bridge
with a working example here:
http://facebooker-authlogic-bridge.heroku.com
Downloading the code, it throws: undefined method 'find_or_create_by_facebook_id' for #<Cl...
I have three models that look something like this:
class Bucket < ActiveRecord::Base
has_many :entries
end
class Entry < ActiveRecord::Base
belongs_to :submission
belongs_to :bucket
end
class Submission < ActiveRecord::Base
has_many :entries
belongs_to :user
end
class User < ActiveRecord::Base
has_many :submissions
end
...
hello,
i have this crazy label for each time i create a migration that use the time instead of a integer. it makes things very hard to switch between the version of the database that you want to use.
i also have this crazy ID for each object that i create :
How can set up rails to have easy version and id numbers.
thank you
...
How do i override/set authlogic to use the email field instead of the username field for both signup and authentication, having a username + an email is occasionally too intense for some some registration scenarios
...
t = Time.now
d = 10.minutes.from_now
Using these two variables, how do I output a timer like 00:10:00?
As d counts down, the timer would show 00:09:59, 00:09:58, etc.
Note: I'd formatting uses Rails datetime format method somehow.
...
I'd like to define a method that is available in both my views and my models
Say I have a view helper:
def foo(s)
"hello #{s}"
end
A view might use the helper like this:
<div class="data"><%= foo(@user.name) %></div>
However, this <div> will be updated with a repeating ajax call. I'm using a to_json call in a controller returns ...
I am trying to use acts_as_audited plugin. Should I be installing it as a gem (put it in environment.rb) or a plugin?
what is the advantage of one over the other. Later on I plan to put this app on the clients server for permanent hosting. so am I better off having it as a gem? if it is as a gem ...when i put the app on the clients ser...
In tag#show I list all entries with that tag. At the bottom of the page I'd like to have something like: "Related Tags: linked, list, of, related tags" My view looks like:
<h2><%= link_to 'Tag', tags_path %>: <%= @tag.name.titleize %></h2>
<% @entries.each do |entry| %>
<h2><%= link_to h(entry.name), entry %></h2>
<%- unless entry...
I've got a plugin that is a bit heavy-weight. (Bullet, configured with Growl notifications.) I'd like to not enable it if I'm just running a rake task or a generator, since it's not useful in those situations. Is there any way to tell if that's the case?
...