最新文章列表

Rails 使用 zh-CN.yml

      当使用 Rails 的 validates 对 User Model 的属性添加限制条件; 用户注册时,提示的信息将出现英文。  下面介绍如何将这些英文翻译成中文。   ...
小嗷喏 评论(0) 有3087人浏览 2014-03-29 15:45

Twitter ratchet twitter_ratchet_rails

Twitter ratchet , 类似于bootstrap,不过专注于mobile,笔者用过在实际项目中,压缩后非常小,十分适合在mobile中使用。 查看官方网站: http://goratchet.com/components/ 同时也快速包装了一个Rails 的gem:  主要依赖于  Ratchet v2.0.1  https://github.com/lanrion/twitt ...
lanrion 评论(0) 有546人浏览 2014-03-13 01:08

rails 在Terminal新建用户

   Rails 在后台新建用户。   user = User.new({:name=>'admin', :password=>'admin', :password_confirmation => 'admin', :is_amdin => true, ...
小嗷喏 评论(0) 有678人浏览 2014-03-08 22:18

Rails 根据 user_agent 判断请求端

   要根据请求端的不同而返回不同的页面,首先就得判断出请求端是pc还是mobile。在http请求时,user_agent这个字段会记录用户所用的设备和浏览器。所以就得对user_agent进行解析,来获取是什么设备。      (1)在Rails项目中,要用到useragent 这个gem 包(https://github.com/josh/useragent)。输入终端命令:   ...
小嗷喏 评论(0) 有2355人浏览 2014-03-05 19:56

Rails flash

flash是个hash用于在两个actions间传递临时数据,flash中存放的所有数据会在紧接着的下一个action调用后清除。一般用于传递提示和错误消息。 class PostsController < ActionController::Base def create # save post flash[:notice] = "Post succ ...
wudixiaotie 评论(0) 有810人浏览 2014-03-02 21:50

Paperclip 删除上传的图片 和 NotIdentifiedByImageMagickError

   1.在成功安装ImageMagick了后对图片处理是出现下面错误:  An error was received while processing: #<Paperclip::Errors::NotIdentifiedBy ImageMagickError: Paperclip::Errors::NotIdentifiedByImageMagickError> ...
小嗷喏 评论(0) 有1408人浏览 2014-03-01 16:07

在heroku上部署Rails和遇到的问题

1.Heroku 使用 PostgreSQL(发音 post-gres-cue-ell,经常简称 Postgres),所以我们要把 pg 加入生产组,Rails 才能和 PostgreSQL 通信: group :production do gem 'pg', '0.15.1' end   2.login heroku $ heroku login   3.heroku cr ...
wudixiaotie 评论(0) 有448人浏览 2014-03-01 12:49

Rails常用命令

test环境数据库签移: $ rake db:migrate RAILS_ENV=test   $ rake test:prepare 启动server的环境变量: $ rails server --environment production 改变控制台环境: $ rails console test  
wudixiaotie 评论(0) 有437人浏览 2014-02-28 16:32

验证唯一性的不足

唯一性验证无法真正保证唯一性。 validates :email, presence: true, format: { with: VALID_EMAIL_REGEX }, uniqueness: { case_sensitive: false }  不会吧,哪里出了问题呢?下面我来解 ...
wudixiaotie 评论(0) 有448人浏览 2014-02-28 15:50

重命名Heroku的app

 如果在Heroku.com的网站上重命名app,不会自动同步到开发机的*.git文件中,需要手工重命名。 $ heroku apps:rename newname  newname是新的app名字。可以参考  
wudixiaotie 评论(0) 有472人浏览 2014-02-27 18:40

Rails Project Init

 1.rspec $ rails generate rspec:install  2.guard $ bundle exec guard init rspec  3.加入默认 Guardfile 的代码,注意顶部的 require require 'active_support/inflector' guard 'rspec', all_after_pass: false do ...
wudixiaotie 评论(0) 有685人浏览 2014-02-26 00:56

Rails里ActiveRecord里字段自动生成的实现。

class Base #定义inherited这个hook,当Base类被model类继承的时候就执行 def self.inherited(model) arr_attr_name = %w{id title body create_by}#这里可以取得model的名字,再到数据库中去查询 arr_attr_name.each do |attr_name| mod ...
wudixiaotie 评论(0) 有549人浏览 2014-02-24 21:21

rails 开发工具 textmate

增强 textmate 功能--- Validate and Save your Ruby in TextMate   http://drnicwilliams.com/2010/06/01/validate-and-save-your-ruby-in-textmate-with-secret-rubinus-superpowers/ 使用 app scrolls生成 rails 项目 Insta ...
52jobs 评论(0) 有425人浏览 2014-02-23 22:59

rails 小技巧

#Rails Tip 1 Actions Are Methods http://errtheblog.com/posts/1-actions-are-methods class PostsController < ApplicationController def list_by_author list :conditions => ['author_id = ?', p ...
52jobs 评论(0) 有574人浏览 2014-02-23 22:55

rails 小代码合集 view controller model

Rails Create an image with link using the image helper <%= link_to image_tag("rails.png", alt: "Rails"), 'http://rubyonrails.org' %>01.gemfile #long_block_rhs.rb def sel ...
52jobs 评论(0) 有1600人浏览 2014-02-23 13:18

rails bash

1、一个完整的rails app自动生成bash 引用#!/bin/bash clear echo -e "Preparing to start ...\n" cd /Users/gelias/workspace/ruby echo -e "removing oldest version ... \n" rm -rf /Users/gelias/work ...
52jobs 评论(0) 有600人浏览 2014-02-22 21:48

实用工具--rails 命令、generator

1、rails 基本 rails new rails-bootstrap -m https://raw.github.com/RailsApps/rails-composer/master/composer.rb rails new User_Auth -d mysql rails new $1 -m https://raw.github.com/RailsApps/rails-com ...
52jobs 评论(0) 有982人浏览 2014-02-22 20:52

ubuntu13.10 Rails环境

 1.安装RVM: $ curl -sSL https://get.rvm.io | bash -s  2.安装依赖: $ rvm requirements  3.安装ruby: $ rvm install 2.0.0  4.修改终端启动脚本: [[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$ ...
wudixiaotie 评论(0) 有560人浏览 2014-02-22 16:21

rails 版本 更新/升级 release note

  升级到 Rails 4,你的应用需要准备什么?   升级到 Rails 4 http://www.oschina.net/translate/get-your-app-ready-for-rails-4?print
52jobs 评论(0) 有554人浏览 2014-02-22 14:02

rails 开发工具相关

#使用TextMate进行Ruby On Rails开发推荐插件 ruby-on-rails-tmbundle https://github.com/drnic/ruby-on-rails-tmbundle/tree/master mkdir -p ~/Library/Application\ Support/TextMate/Bundles cd ~/Library/Application\ ...
52jobs 评论(0) 有461人浏览 2014-02-21 20:14

最近博客热门TAG

Java(141747) C(73651) C++(68608) SQL(64571) C#(59609) XML(59133) .net(54785) 编程(39454) JSP(37542) 数据结构(36423) Eclipse(31253) PHP(29988) F#(26079) 算法(24867) 脚本(19840) J#(18922) JDBC(17888) ASP(17480) JDK(14881) JVM(14450)

博客人气排行榜

    博客电子书下载排行

      >>浏览更多下载

      相关资讯

      相关讨论

      Global site tag (gtag.js) - Google Analytics