An simple example
Create database, migration and popule database
| task :add_posts => :environment do | |
| require 'nokogiri' | |
| require 'mechanize' | |
| require 'json' | |
| # 88198 | |
| def dados(categoria) | |
| j = 0 | |
| 4.times do |i| | |
| # Additional translations at https://github.com/plataformatec/devise/wiki/I18n | |
| # Este arquivo deve ser colocado em config/locales/devise.pt-BR.yml | |
| pt-BR: | |
| devise: | |
| invitations: | |
| edit: | |
| header: "Confirmar cadastro" | |
| submit_button: "Confirmar" | |
| user: |
| pt-BR: | |
| date: | |
| abbr_day_names: | |
| - Dom | |
| - Seg | |
| - Ter | |
| - Qua | |
| - Qui | |
| - Sex | |
| - Sáb |
| # PostgreSQL. Versions 8.2 and up are supported. | |
| # | |
| # Install the pg driver: | |
| # gem install pg | |
| # On OS X with Homebrew: | |
| # gem install pg -- --with-pg-config=/usr/local/bin/pg_config | |
| # On OS X with MacPorts: | |
| # gem install pg -- --with-pg-config=/opt/local/lib/postgresql84/bin/pg_config | |
| # On Windows: | |
| # gem install pg |
| // COLOCA ISSO NA VIEW QUE VAI BUSCAR O CEP | |
| function jsBuscaCep() { | |
| var cep = document.getElementById( "ID DO CAMPO QUE ESTÁ o CEP" ).value; | |
| $.getJSON("http://cep.republicavirtual.com.br/web_cep.php?formato=query_string&cep=" + cep, | |
| function ( data ) { | |
| console.log(data); | |
| $("#user_endereco").val(data.tipo_logradouro + ' ' + data.logradouro); | |
| $("#user_bairro").val(data.bairro); | |
| $("#user_cidade").val(data.cidade); | |
| $("#user_estado").val(data.uf); |
| # Tu vai ter que configurar uma route para chamar aqui, que vai ser o mesmo link que está setado no javascript no arquivo anterior | |
| def busca_por_cep | |
| render :json => BuscaEndereco.cep(params[:cep]) | |
| rescue RuntimeError | |
| render :json => ["", "zipcode nao encontrado", "", "", ""].to_json | |
| end |
| task :add_posts => :environment do | |
| require 'nokogiri' | |
| require 'mechanize' | |
| require 'json' | |
| # 88198 | |
| def dados(categoria) | |
| j = 0 | |
| 4.times do |i| | |
| class Company < ActiveRecord::Base | |
| # Relations | |
| belongs_to :user | |
| belongs_to :type | |
| has_many :posts | |
| has_many :members | |
| accepts_nested_attributes_for :members, :reject_if => :all_blank, :allow_destroy => true | |
| Started POST "/users/password" for 192.168.2.1 at 2015-03-29 02:41:38 -0300 | |
| Processing by Devise::PasswordsController#create as HTML | |
| Parameters: {"utf8"=>"✓", "authenticity_token"=>"uAmZC6C1mFqombDEK7S1uS8gWZWajtxszjgOr01O+M4=", "user"=>{"email"=>"henrique@breim.com.br"}, "commit"=>"Me envie um e-mail para trocar a senha"} | |
| User Load (0.8ms) SELECT "users".* FROM "users" WHERE "users"."email" = 'henrique@breim.com.br' ORDER BY "users"."id" ASC LIMIT 1 | |
| User Load (0.9ms) SELECT "users".* FROM "users" WHERE "users"."reset_password_token" = '87d0b4cf9a08f9d5450e589849ad20e9dc34ee02a84d037d3efc786d0a36d740' ORDER BY "users"."id" ASC LIMIT 1 | |
| (2.1ms) BEGIN | |
| SQL (0.6ms) UPDATE "users" SET "reset_password_sent_at" = $1, "reset_password_token" = $2, "updated_at" = $3 WHERE "users"."id" = 7 [["reset_password_sent_at", "2015-03-29 05:41:38.845826"], ["reset_password_token", "87d0b4cf9a08f9d5450e589849ad20e9dc34ee02a84d037d3efc786d0a36d740"], ["updated_at", "2015-03-29 05:41:38.850709"]] | |
| Search Load |