`
CaiDeHen
  • 浏览: 94269 次
  • 性别: Icon_minigender_1
  • 来自: 成都
社区版块
存档分类
最新评论
文章列表
    一直以来我的网站存在着一个令人很崩溃的问题。就是用户上传的图片会丢失。而且是连带相册一起丢失。开始还以为是什么地方误删了,冲突了。查了很久很久无果。关键是这个BUG并不是一定出现。而且,我测试时就从来没碰到过。     昨天一个用户刚注册,开始上传图片。我就密切注意。过了一会儿,果不然,相册丢失了。很纳闷。打开production.log看了N久。没发现异常啊。注:里面我没加sql的log。太多了。     但是这个问题很郁闷,而且已经郁闷很长一段时间了。这个用户还好。又继续新建相册,传照片。一会儿。又没了。这就郁闷了。我就不得不重新开了sql的log。果不然,确实有album dest ...
edit_in_place确实是个不错的效果。但是对于 主流用户 来说,输入框还有优于它的。为什么呢?因为你EIP在那,很多人不知道是可以点击修改的。好吧。你说后面加个提示,行,然后发现用户华丽的去点后面的提示,发现不能改… ...
Discover how to dynamically change the layout using content in the database. Check out this episode for details. script/generate migration add_layout_to_blogs layout_name:string custom_layout_content:text rake db:migrate gem install liquid # controllers/application.rb def load_blog @current ...
You know those invitation systems where a given user can invite a number of other people to join? That's what I show you how to make in this episode. script/generate nifty_scaffold invitation sender_id:integer recipient_email:string token:string sent_at:datetime new script/generate migration add_in ...
Learn how to unleash the full potential of subdomains with the subdomain-fu Rails plugin in this episode. Domain Name Solutions As mentioned in the episode, you’ll need to add each subdomain to /etc/hosts. This can be a problem if subdomains can be generated dynamically. It would be nice if we coul ...
Tired of juggling multiple Rails apps around with script/server? See how to set up Passenger in development so each one has its own local domain name. Sorry to make this platform specific. It looks like Passenger isn’t available on Windows. sudo gem install passenger sudo passenger-install-apache2-m ...
This episode will show you how to make a model which isn't based on Active Record. You may want to do this if a resource isn't backed by the database. # models/letter.rb class Letter attr_reader :char def self.all ('A'..'Z').map { |c| new(c) } end def self.find(param) ...
If you need a full text search engine, Thinking Sphinx is a great solution. See why in this episode. script/plugin install git://github.com/freelancing-god/thinking-sphinx.git rake thinking_sphinx:index rake thinking_sphinx:start # models/author.rb define_index do indexes content indexes ...
If you have a lot of logic associated with the data inside a session, you'll need some central location to put this logic. See how to create a session based model in this episode. # models/user_session.rb class UserSession def initialize(session) @session = session @session[:comment_id ...

#118 Liquid

Liquid is a safe way to provide a powerful template language to the site's users. See how in this episode. <!-- pages/show.html.erb --> <%= liquidize @page.content, 'page' => @page %> # environment.rb config.gem 'liquid' # application_helper.rb def liquidize(content, argument ...
Static pages can sometimes be a little awkward to add to a Rails app. See a couple different solutions to this problem in this episode. # pages_controller.rb def show if params[:permalink] @page = Page.find_by_permalink(params[:permalink]) raise ActiveRecord::RecordNotFound, "Page ...
Selenium is a great way to test your app automatically through a browser. See how it works in this episode. script/plugin install git://github.com/ryanb/selenium-on-rails.git script/generate selenium destroy_product.rsel # test/selenium/destroy_product.rsel setup :fixtures => :all product = ...
Rails 2.1 brings some new caching features which makes it very easy to cache any values including models. See how in this episode. # script/console Rails.cache.write('date', Date.today) Rails.cache.read('date') Rails.cache.fetch('time') { Time.now } cache = ActiveSupport::Cache.lookup_store(:mem_ ...
Ever wondered how some sites seem to have endless scrolling page with no pagination? Find out how easy it is to do this in Rails in this episode. # products_controller.rb def index @products = Product.paginate(:page => params[:page], :per_page => 15) end # index.js.rjs page.insert_html ...
The scoped method allows you to generate named scopes on the fly. In this episode I show how to use anonymous scopes to improve the conditional logic which was used in the previous episode on advanced search form. # config/initializers/global_named_scopes.rb class ActiveRecord::Base named_scope : ...
Global site tag (gtag.js) - Google Analytics