Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.
$ python -m SimpleHTTPServer 8000
Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.
$ python -m SimpleHTTPServer 8000
Original - https://gist.github.com/ramontayag/1045123
Problem: I learned how to run RSpec to test classes and modules in my gem. But, if I wanted to test my gem as if it were already included in a Rails app, I couldn't find much info about it online.
I usually do unit tests with RSpec, and I test the whole stack with Cucumber. So here we will just setup Cucumber to run the Rails app that you embed in your gem.
Before we begin:
Accepts Nested Attribute with a virtual attribute | |
I have a Project model which accepts nested attributes for tasks. And Task has a virtual attribute "name". So every time I change the name, it gets persisted as encrypted_task_name before update. On the project edit page the form has a input field for task name (and not encrypted_task_name). When I change the name and since name is a virtual attribute, Rails doesn't detect a change in Task and doesn't update that task while updating Project. | |
How do I make sure that task is saved even if its virtual attributes are changed during Project update? | |
One option that I don't want to use is :autosave => true on task.rb since I task is rarely updated. | |
--------- | |
I ran into the same problem. Using :autosave => true didn't even work for me. I managed to solve it by adding attribute_will_change!(:my_virtual_attribute) to the writer for my virtual attribute. So, in your case: |
# cap staging rake TASK=ts:config | |
namespace :rake do | |
desc "remote rake task" | |
task :default do | |
run "cd #{current_path}; RAILS_ENV=#{rails_env} rake #{ENV['TASK']}" | |
end | |
end |
# encoding: utf-8 | |
namespace :db do desc "Backup project database. Options: DIR=backups RAILS_ENV=production MAX=7" | |
task :backup => [:environment] do | |
datestamp = Time.now.strftime("%Y-%m-%d_%H-%M-%S") | |
base_path = Rails.root | |
base_path = File.join(base_path, ENV['DIR'] || "backups") | |
backup_base = File.join(base_path, 'db_backups') | |
file_name = "#{datestamp}_#{Rails.env}_dump.sql" | |
backup_file = File.join(backup_base, file_name) |
$(document).ready(function() { | |
scheduler.config.xml_date="%Y-%m-%d %H:%i"; | |
scheduler.config.start_on_monday = false; | |
scheduler.config.show_loading = true; | |
scheduler.config.prevent_cache = true; | |
/* | |
scheduler.config.collision_limit = 1 | |
scheduler.attachEvent("onEventCollision", function (ev, evs){ | |
console.log(ev); | |
console.log(evs); |
http://codepen.io/akademy/pen/FlkzB |
#Model | |
@user.should have(1).error_on(:username) # Checks whether there is an error in username | |
@user.errors[:username].should include("can't be blank") # check for the error message | |
#Rendering | |
response.should render_template(:index) | |
#Redirecting | |
response.should redirect_to(movies_path) |
(function (exports) { | |
function urlsToAbsolute(nodeList) { | |
if (!nodeList.length) { | |
return []; | |
} | |
var attrName = 'href'; | |
if (nodeList[0].__proto__ === HTMLImageElement.prototype | |
|| nodeList[0].__proto__ === HTMLScriptElement.prototype) { | |
attrName = 'src'; | |
} |
# check that all assets have the correct encoding | |
# https://gist.github.com/1301199 | |
namespace :assets do | |
desc "Check that all assets have valid encoding" | |
task :check => :environment do | |
paths = ["app/assets", "lib/assets", "vendor/assets"] | |
extensions = ["js", "coffee", "css", "scss"] |