Hi, I'm a rails newbie.
I'm trying to create a link on a show page, with part of the data coming from a stored field which is the subdomain. I can't save the full link before the save in the model because I'm using just the sub-domain info for a script that's running.
So, for example, I'm saving "subdomain" in the database but on a ...
I have three models: paste, snippet and tutorial. I want to show the newest of all of them mixed in one list, like this on the page:
<ul>
<li>Just a paste</li>
<li>The worst snippet ever (-10202343 kudos) (1 quadrillion comments)</li>
<li>Just another paste</li>
<li>Ruby on Rails tutorial (5 kudos) (2 comments)</li>
<li>Another snippet<...
I have a before_filter to set a arel relation, but then if I call first in the method it doesn't like it. It seems to work fine in the console. What am I missing here?
class TeamsController < ApplicationController
before_filter :find_team
def show
@team.first
end
private
def find_team
@team = Team.where(:id => para...
I'm developing a rails app where the user needs to be able to create an account & login with either facebook OR twitter.
It seems pretty straightforward if I want to do one or the other, but implementing both looks like it could present some difficulty.
Does anybody else have any experience with implementing both Twitter's oauth and Fa...
I am creating a snippet-site where people can rate snippets, just like votes on SO. Currently, when a snippet has over 999 kudos, it looks like on this mug:
So what I want is to do a 1K, 1M, etc... kudos like on SO:
-----
|999|
-----
**user does +1**
-----
|1K |
-----
**one million kudos**
-----
|1M |
-----
The same goes for billi...
When I deploy my rails app (which uses restful_authentication), to Heroku, I get the following errors:
/usr/local/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:105:in `const_missing': uninitialized constant User::Authentication (NameError)
from /disk1/home/slugs/216145_64fa92e_1859/mnt/app/models/user.rb...
I have this haml:
.kudobox
%div.kudos= number_to_human_size_not_bytes kudos
%div= (kudos == 1 || kudos == -1) ? "kudo" : "kudos"
Now I want the .kudobox have a positive, negative or zero class, depending on the number of kudos:
-# < 0 kudos
<div class="kudobox negative">
-# == 0 kudos
<div class="kudobox zero">
-# > 0 kudos
<di...
I'm receiving many failed login requests from spammers/bots that are trying to brute-force the credentials, also I'm receiving many requests to pages like /forum/index.php.
I wrote a script to parse the IP's of those attackers from production.log:
#!/bin/bash
# Failed Logins
grep "Failed " ~/app/log/production.log | egrep -o -e "[0-9]...
How can I write the code below so that it passes the user.id. Given what I have, it throws Class id not found error. (User has many fights. And Fight belongs to user. User can either be a challenger in the fight, or a challengee in the other.)
has_many :fight_wins, :class_name => 'Fight', :foreign_key => 'challenger_id or challengee_...
In my Rails application there are some metrics about the content of the database I made available in an administration interface (number of users, number of users with actual data, rate of usage, numbers of database records in various tables). I can get this information at any point in time, but I want to log and graph historical data so...
Artists have many Events. Events have many Artists. The join between these two models is called Performances.
Currently the Event form creates the Performance but creates a new artist for each Artist added to the Event form.
I would like the Event form to:
Validate that an Artist can only be added to an Event once
If an Artist with t...
I have three models of concern here:
User
Fight
FightPunches
Punches
The associations are as follows:
User has many fights, foreign_key => 'challenger_id or challengee_id'
Fight belongs to challenger, as User
Fight belongs to challengee, as User
Fight has many fight_punches
FightPunches belongs to fight
Fight has many punches, thro...
Hey,
I have a form where users can enter an isbn and it will try to lookup book data and save it.
When validation fails for the isbn lookup (for example if somebody entered it incorrectly), I would like it to redirect to another form where users can enter data in manually if the isbn lookup fails (but not if other validations like numer...
I've decided to put a landing page on my website goldhat.org. I want users to be able to go directly to this page if they are logged in and be directed to a landing page if they aren't logged in. The landing page is currently sitting here. If one clicks on the "browse website" link at the top, it will go to what is currently the home pag...
I want to execute a custom validation before the record is created?
It looks as if this is the right method: before_validation_on_create. For example:
before_validation_on_create :custom_validation
But am not sure. Any help would be appreciated.
...
i am looking to build a ruby on rails application that would be built off of community engine or tog.
id like to know if there was a gem out there that would add recommendation capability to these or any ideas folks out there might have as to building this network
thx
sg
...
Say I have Users and Things. Instead of /users/joe/things/1, I want the path to be just /joe/things/1. I've tried the default_routes plugin but using it breaks link_to routes.
...
I have a blog application and I want to use my own markup language for writing posts. It's syntax is similar to Textile and Wiki. What is the simplest way to do this? Maybe there is some markup language builder gem where I can just set up the rules?
I use Rails 3 and Haml templates.
...
eg: There are 2 files in controller folder:
so in the left navigation box we'll see:
controller
|——low_quotation_controller.rb
|__quotation_controller.rb
In netbean 6.5,when i input 'q' in the navigation box,it will match quotation_controller.rb
but now in netbean 6.9,it match low_quotation_controller.rb first
I don't like this match m...
I have a model 'User', it's a restful resource, and has the default methods like 'index, show, new, create' and others.
Now, I want to define a new action 'current_user', to show the information of current logged-in user, which is different from 'show'.
When I use:
link_to current_user.name, :controller=>'users', :action=>'current_use...