Hi,
Strange thing – I have Authentication module in lib/ like this:
module Authentication
protected
def current_user
User.find(1)
end
end
and in ApplicationController I'm including this module and all helpers, but method current_user is available in controllers, but not from views :( How can I make this work?
...
Profiler/profiling related issue with Cucumber testing.
One of our cucumber tests run fairly slow. In stead of guessing on where our application is spending time, I'd like to know programatically.
How do I trigger a cucumber test with a profiler???
What did not work:
$ URL=/projects/by/114951412 #URL to slow rails page
$ script/...
I'm trying to figure out whether I can call the validate method twice in an ActiveRecord model definition. Once, of course, would be in a mixin.
So the first question is, is it okay to put this method in a mixin:
validate :check_them_dates
and not worry if classes that include me will want to call validate as well?
I have alread...
What are the practices to prevent XSS in Ruby on Rails?
I found many old docs on the web and most of the time it was all about using
h/html_escape helper to escape any variable that comes from users.
I understood from newer docs that in the version 2.0 and above there is
sanitize method that is automatically cleaning the input from su...
Hi, I defined a custom method in application_helper.rb file like the following:
def rxtrnk(line)
rxTRNK = /\w{9,12}/m
trnks = Array.new
i = 0
while i <= line.size
if line[i].match(rxTRNK)
trnks[i] = line[i].scan(rxTRNK)
end
i += 1
end
return trnks
end
Then I tried to call it from a view ...
I have a recursive relationship between models:
Test
--> Questions
-------> (has_one) Remediation
------------> (has_many) Remediation_Questions
-----------------> (has_one) Question
Basically the idea is each question has a remediation (some link or block of text) associated with it. Each Remediation then has a set of remediation que...
I'm experimenting with using ext_scaffold to generate UI elements for a Rails-backed web application.
However, I'm experiencing issues with the behavior of boolean fields. For instance, when I do
./script/generate ext_scaffold product name:string description:text sku:integer available:boolean
It builds the migration properly and gene...
Hello.
I'm trying to create a registration form with Rails. It's working, but it doesn't displays the errors from the validation (it validates, but the errors don't display).
Here are my files:
# new.html.erb
<h1>New user</h1>
<% form_for :user, :url =>{:action=>"new", :controller=>"users"} do |f| %>
<%= f.error_messages %>
<p>
...
Hi all,
I could use some help figuring out what's going on. Check the log output below -- why would rails treat the two renders differently? Why does one succeed, without any related SQL calls and the second fail -- with an SQL access. (It's not an ActiveRecord model, no SQL should be involved in this render.)
Background
I have a cu...
Hi all,
I have a Comment model that belongs_to a Message. In comments.rb I have the following:
class Comment < ActiveRecord::Base
belongs_to :message, :counter_cache => true, :touch => true
end
I've done this because updating the counter_cache doesn't update the updated_at time of the Message, and I'd like it to for the cache_key....
So I am trying to use a flash uploader (specifically uploadify, but tried swfuploader as well) and for some reason the progress isn't being tracked correctly. I am about to give apache a try, but would prefer to use nginx due to its lower memory consumption and speed. Now this isn't an issue with an upload_progress module, since flash it...
Hi all,
I'm using restclient for a multipart form to send data to a restful web service (it's Panda video encoding service).
The trick though, is that the file I am passing into restclient (Technoweenie branch) is coming from my own form that a user submits.
So, lets walk through this. A user posts a file to my rails app. In my control...
Rather than an acts_as_foo syntax**, I'm toying with the idea of extending ActiveSensor::Base < ActiveRecord::Base and then extending this base class with all the errors/validations/class methods/whizbangs.
Proposed: #active_sensor.rb gem
module ActiveSensor
include ActiveRecord
autoload :VERSION, 'active_sensor/version'
autoloa...
I have a cucumber step that recently started failing when an was added to my layout. If I take the out, my tests all pass. When I put it back in, every test that uses the click_link method supplied by WebRat fails with the following message:
And he follows 'Unsubscribe'
incompatible encoding regexp match (UTF-8 regexp ...
I have the following entities:
User
Company
Organization
Users need to be able to add Users, Companies, Organizations, and future party objects to their friend list.
My original idea involved using a Friendship object with a polymorphic relationship to the friend like so:
Simplified Friendship schema:
user_id
friendable_id
friend...
So i have my destroy command. The problem is I don't want my users to be able to delete this category if it contains items. So I have an if statement in my destroy method. That works all great, but I'm using AJAX to have the page not load and using a destroy.js.erb file. My method is below:
def destroy
@promotion_type = PromotionTyp...
Is there a way in the Ruby On Rails Routing framework to make a decision about which controller or action to call based on some logic all within a single route?
For example, let's say have a url zip/354 and I want to call the foo action if the integer is even and the bar action if the integer is odd. To use pseudo-ruby:
map.connect 'z...
I wrote a sync script to upload a local file if it does not exist on the ftp server.
I want to make it more robust by ensuring that the file size on each match. This will allow the script to correct the file if it was interrupted during an upload.
What is the best way to get the file size for both the remote and local files.
I am usin...
I have a application which stores documents created by users. These documents have authors, creation dates. The authors can have roles. Additionally a given document may get tagged with keywords. There are ~16K documents in the database, and a user may want to view the documents with any combination of this information as a limit. F...
I need to have a view able to update an array attribute on a model such that I can dynamically add things on the view to be able to add this. Does that even make sense?
Basically a Foo has urls. So in the DB I just have a text datatype that I want to store the comma separated list of urls, and I override the default AR setter and getter...