This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<% form.inputs :name => "Datos de acceso" do %> | |
<%= form.input :email %> | |
<%= form.input :password %> | |
<%= form.input :password_confirmation %> | |
<% end %> | |
<% @user.build_profile(:contact_email => @user.email) unless @user.profile %> | |
<% form.semantic_fields_for :profile do |profile| %> | |
<% profile.semantic_fields_for :address do |address| %> | |
<%= address.input :address, :as => :select, :label_method => :name %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Selector de idioma | |
#dependencias: | |
# 1 - Rack locale del paquete Rack-contrib [1] | |
# USO: Se usa para detectar el idioma definido por el usuario en su browser ['HTTP_ACCEPT_LANGUAGE'] | |
# Esplicado aquí http://guides.rubyonrails.org/i18n.html#using-accept-language | |
# [1] http://github.com/rack/rack-contrib | |
# 2 - Routing-filter [1] | |
# USO: Establecer el locale en las URLs ej.: www.mysite.com/es/foo/bar | |
# NOTA: Si tambien quieres traducir las URL's usa la gema de Raul Murciano Translate_routes [2] (De momento sin cobertura para Rails3) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@register.tag | |
def ifmatches(parser, token): | |
lst = token.split_contents() | |
val = lst[1] | |
regex = lst[2] | |
nodelist_true = parser.parse(('else','endifmatches',)) | |
token = parser.next_token() | |
if token.contents == 'else': | |
nodelist_false = parser.parse(('endifmatches',)) | |
parser.delete_first_token() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# PROBLEMA: | |
# ¿Cómo hacer que N tipos diferentes de objetos compartan atributos/campos comunes? | |
# Para resolver el problema se me ocurren 3 opciones | |
# A) CON RELACIONES POLIMORFICAS | |
# B) STI | |
# C) TODO EN UNA UNICA TABLA | |
# | |
# ----------------------------------------------------------------------------------------------------------- | |
# A) CON RELACIONES POLIMORFICAS: | |
# NOTA: No estoy seguro, pero creo que esto mismo funcionaria si fuera has_one en lugar de has_many. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# http://en.wikipedia.org/wiki/Stop_words | |
es_STOPWORDS = [ | |
'de','a','que','en','para', | |
'por','le','la','lo','las','los','el', | |
'una','un','cada' | |
] | |
en_STOPWORDS = [ | |
'I','a','about','an','are', | |
'as','at','by','com','for', | |
'from','how','of', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Esto es un pequeño script que tengo para rellena mi BBDD de desarrollo: | |
# ----------------------------------------------------------------------- | |
require 'faker' | |
namespace :db do | |
desc "Fill database with sample data" | |
task :populate => :environment do | |
Rake::Task['db:reset'].invoke | |
jobs_categories = %w[undergraduate predoctoral postdoctoral associate_prof assistent_prof research_prof technician] | |
address = Address.create!( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Elementos necesarios para hacer un backup periodico de BBDD y archivos con Ruby | |
backup [1] + planeados (cron) con whenever [1] + capistrano (deploy) [3] | |
NOTA: | |
backup tiene diversas estrategias para hacer el backup (scp, ftp, S3,...) | |
Hacer una cuenta de Amazon S3 y probarlo. | |
[1] https://rubygems.org/gems/backup |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
url = 'http://www.example.com/form' | |
values = {'param1' : '3','param2' : '29'} | |
data = urllib.urlencode(values) | |
req = urllib2.Request(url) | |
req.add_data(data) | |
try: | |
html = urllib2.urlopen(req) | |
except HTTPError, e: | |
ss.invalid_links += 'HTTP Error ERROR en el listado code => %s \n URL=> %s\n' % (e.code,url) | |
except URLError, e: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Intervienen en esta función los siguiente modelos | |
1- User | |
2- Profile | |
3- Publication | |
4- ProfilePosition | |
User es donde gestiono la autenticacion. Pero la informacion del miembro la almaceno en Profile. | |
Un Profile tiene muchas publicaciones y una publicacion tiene muchos profiles. Todo a traves de ProfilePosition | |
Estos son los modelos: | |
class User < ActiveRecord::Base |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<VirtualHost *:80> | |
ServerName appname.local | |
DocumentRoot "/Users/andres/Documents/SOFTWARE/RAILS/App/2/appname/public" | |
RailsEnv development | |
<Directory "/Users/andres/Documents/SOFTWARE/RAILS/App/2/appname/public"> | |
AllowOverride all | |
Order allow,deny | |
Allow from all | |
</Directory> |
OlderNewer