Skip to content

Instantly share code, notes, and snippets.

View juanm55's full-sized avatar

JuanManuel LF juanm55

View GitHub Profile
@juanm55
juanm55 / gem list local output
Created August 23, 2011 15:56
a simple list of outputs i keep getting trying to install mongrel
$ gem list --local
*** LOCAL GEMS ***
abstract (1.0.0)
actionmailer (3.0.10)
actionpack (3.0.10)
activemodel (3.0.10)
activerecord (3.0.10)
activeresource (3.0.10)
@juanm55
juanm55 / 20110909202649_create_evaluator_relations.rb
Created September 9, 2011 20:28
just some error im getting trying to do a migration in rails 3
#the actual migration generated....
class CreateEvaluatorRelations < ActiveRecord::Migration
def self.up
end
def self.down
end
end
@juanm55
juanm55 / en.yml
Created September 23, 2011 15:43
Is this possible in i18n???
en:
editing: "editing %{thingy}"
another: "User"
# the idea is that I can call a dict definition from within another one?
#maybe im better off doing something like this:
#in view
t 'editing', :thingy => t('another')
@juanm55
juanm55 / gist:1324560
Created October 29, 2011 15:06
HTML links with images that aren't underlined
/* the idea here is to create a link with an image AND some text,,,, but ONLY the text gets underlined*/
/* with this setup and CSS it is not possible to take out the underline of the img element (since it is an in-line element)*/
<a href=#><img src="path/to/file" /> some text</a>
/* Because 'a' styling is supposed to have text-decoration:underline; and that affects the image too....
even with:
@juanm55
juanm55 / ob_evidences_controller.rb
Created November 9, 2011 21:38
How should I do this?
# I want to go from the session information (which contains the current logged in user_id) to his/her assigned EvaluationUser, down to his'/hers EvaluationCategories, down to the objectives associated to those, and finally the evidences related to each one of them....
#the idea is being able to obtain and array of ob_evidences that the user has created.... but the following does not seem to work even though I have the associations which should make everything run swiftly,,,,
def index
@ob_evidences = EvaluationUser.where("user_id = ?", session[:user_id]).first.evaluation_categories.objectives.ob_evidences
end
@juanm55
juanm55 / gist:1407508
Created November 30, 2011 01:17
a question regarding select tag in rails form helper...
<td>Project<br/ >
<%= f.select :project_id, Project.all.collect{|a| [a.name, a.id]}%></td>
# the idea would be to do something similar to what one can do with text_tag
<%= text_tag :comment, :size => 10 %> # which renders a text_input element,,, with 10 spaces for character input...
@juanm55
juanm55 / gist:1501335
Created December 20, 2011 11:55
setting up a rails env in ubuntu!
I recommend getting the 10.04 LTS version meanwhile, but if you feel "edgy" you can get the latest one (though I haven't tested how easy it is to install Ruby there)
OS:
http://www.ubuntu.com/download/ubuntu/download
RUBY and everything else using RVM:
http://ryanbigg.com/2010/12/ubuntu-ruby-rvm-rails-and-you/
Firefox: 1st uninstall the default one (is not linked to the ones in the repositories -- easily done through Ubuntu Software Center)
then in the terminal =>
@juanm55
juanm55 / gist:1670943
Created January 24, 2012 16:22
interesting way of updating text field in rails... without ajax requests....
<%= select_tag("objective[indicator_id]", options_for_select([["seleccione indicador",0]] + @indicators.map {|u| [u.name,u.id]}, selected = var_indicator ) , html_options = {:onchange => "this.form.elements['objective[criteria]'].value = this.form.elements['tmp_objective[indicator_id]'].options[ this.form.elements['objective[indicator_id]'].selectedIndex ].text "}) %>
<%= text_area_tag "objective[criteria]", var_criteria.to_s , :rows => 5, :cols => 70 %></td>
<div style="display:none;VISIBILITY:none;" >
<%= collection_select("tmp_objective", "indicator_id" , @indicators, "id", "suggested_criteria", options ={:prompt=>""}) %>
</div>
@juanm55
juanm55 / pages_controller.rb
Created February 18, 2012 00:18
something I did to avoid using 2 root_paths in my routes
def home
# get 'login', :to => 'devise/sessions#new' in my routes.rb
redirect_to 'login' unless current_user #if not logged in, kick him out of here!
end
@juanm55
juanm55 / fibonacci.rb
Created February 21, 2012 00:34
fibonacci :D, in ruby, trying to make it smaller and lighter
def fibonacci(n)
a = [1,1]
(n-2).times{ a[a.index(a.min)] = a[0]+a[1]}
a.max
end