![](https://img-blog.csdnimg.cn/20201014180756757.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
Railscasts
iteye_19623
这个作者很懒,什么都没留下…
展开
-
#101 Refactoring Out Helper Object
If you have complex view logic, this can easily lead to helper methods which call each other. See how to refactor this out into another object in this episode.[code="java"]# application_helper.rbd...原创 2008-12-12 11:31:37 · 90 阅读 · 0 评论 -
#102 Auto-Complete Association
Usually a select menu is used for setting a belongs_to association, but in this episode I will show you how to use a text field with auto completion.[code="java"]script/plugin install auto_complete...原创 2008-12-12 11:34:33 · 97 阅读 · 0 评论 -
#103 Site Wide Announcements
Sometimes you need to display an administrative announcement to every page on the site and give the users the ability to hide the announcement. See how in this episode.[code="java"]script/generate s...原创 2008-12-12 11:42:29 · 198 阅读 · 0 评论 -
#104 Exception Notifications
If you're running a production site, it's a good idea to record all exceptions which occur. See how to set up a notification system which does that in this episode.Note: I forgot to mention, the exc...原创 2008-12-12 11:48:10 · 103 阅读 · 0 评论 -
#106 Time Zones in Rails 2.1
In the past, time zones have been very difficult to work with, but no longer! Rails 2.1 brings with it great time zone support as you can see in this episode.[code="java"]rake time:zones:local...原创 2008-12-12 12:48:11 · 115 阅读 · 0 评论 -
#107 Migrations in Rails 2.1
Migrations now have a timestamp as their version number in Rails 2.1. In this episode I will explain this change as well as show you some other cool additions.[code="java"]# in a migration filedef...原创 2008-12-12 12:49:07 · 67 阅读 · 0 评论 -
#108 named_scope
The named_scope method in Rails 2.1 makes performing finds on models very elegant and convenient. See how in this episode.[code="java"]# models/product.rbclass Product < ActiveRecord::Base belo...原创 2008-12-12 12:52:26 · 96 阅读 · 0 评论 -
#109 Tracking Attribute Changes
Rails 2.1 keeps track of the changes you make to a model's attributes. It also allows you to see what the previous value was. But watch out for the gotcha! See this episode for details.[code="java"]...原创 2008-12-12 12:54:41 · 101 阅读 · 0 评论 -
#110 Gem Dependencies
In Rails 2.1 we now have the ability to set gem dependencies. Now it's easier than ever to specify which ruby gems our rails app relies on.[code="java"]# config/environment.rbconfig.gem "RedCloth"...原创 2008-12-12 12:57:39 · 86 阅读 · 0 评论 -
#111 Advanced Search Form
If you need to create an advanced search with a lot of fields, it may not be ideal to use a GET request as I showed in episode 37. In this episode I will show you how to handle this by creating a Sear...原创 2008-12-12 13:27:01 · 134 阅读 · 0 评论 -
#112 Anonymous Scopes
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...原创 2008-12-12 13:32:13 · 123 阅读 · 0 评论 -
#114 Endless Page
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.[code="java"]# products_controller.rbdef index @...原创 2008-12-12 13:50:11 · 158 阅读 · 0 评论 -
#115 Caching in Rails 2.1
Rails 2.1 brings some new caching features which makes it very easy to cache any values including models. See how in this episode.[code="java"]# script/consoleRails.cache.write('date', Date.today)...原创 2008-12-12 14:07:54 · 104 阅读 · 0 评论 -
#116 Selenium
Selenium is a great way to test your app automatically through a browser. See how it works in this episode.[code="java"]script/plugin install git://github.com/ryanb/selenium-on-rails.gitscript/gen...原创 2008-12-12 14:11:15 · 86 阅读 · 0 评论 -
#117 Semi-Static Pages
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.[code="java"]# pages_controller.rbdef show if params[:perm...原创 2008-12-12 14:20:43 · 96 阅读 · 0 评论 -
#118 Liquid
Liquid is a safe way to provide a powerful template language to the site's users. See how in this episode.[code="java"] @page %># environment.rbconfig.gem 'liquid'# application_helper....原创 2008-12-12 16:18:24 · 114 阅读 · 0 评论 -
#119 Session Based Model
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.[code="java"]# mo...原创 2008-12-12 16:41:54 · 92 阅读 · 0 评论 -
#120 Thinking Sphinx
If you need a full text search engine, Thinking Sphinx is a great solution. See why in this episode.[code="java"]script/plugin install git://github.com/freelancing-god/thinking-sphinx.gitrake th...原创 2008-12-12 16:59:56 · 86 阅读 · 0 评论 -
#121 Non Active Record Model
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.[code="java"]# models/letter.rbclass Letter...原创 2008-12-13 15:47:32 · 105 阅读 · 0 评论 -
#122 Passenger in Development
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 l...原创 2008-12-13 15:51:19 · 121 阅读 · 0 评论 -
#123 Subdomains
Learn how to unleash the full potential of subdomains with the subdomain-fu Rails plugin in this episode.Domain Name SolutionsAs mentioned in the episode, you’ll need to add each subdomain to ...原创 2008-12-13 15:56:37 · 218 阅读 · 0 评论 -
#124 Beta Invitations
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.[code="java"]script/generate nifty_scaffold inv...原创 2008-12-13 21:37:06 · 132 阅读 · 0 评论 -
#125 Dynamic Layouts
Discover how to dynamically change the layout using content in the database. Check out this episode for details.[code="java"]script/generate migration add_layout_to_blogs layout_name:string custom...原创 2008-12-13 21:41:10 · 109 阅读 · 0 评论 -
#1 Caching with Instance Variables
Learn a quick way to improve performance. Just store the end result of an expensive command in an instance variable![code="java"]# application.rbdef current_user @current_user ||= User.find(s...原创 2008-12-02 21:23:42 · 57 阅读 · 0 评论 -
#2 Dynamic find_by Methods
Shorten simple finds considerably and improve readability by using the dynamic find_all_by and find_by methods.[code="java"]# tasks_controller.rbdef incomplete @tasks = Task.find_all_by_compl...原创 2008-12-02 21:24:51 · 64 阅读 · 0 评论 -
#3 Find Through Association
No need to pass foreign keys in find conditions, just do the find through a has_many association.[code="java"]# projects_controller.rbdef show @project = Project.find(params[:id]) @tasks =...原创 2008-12-02 21:26:20 · 108 阅读 · 0 评论 -
#4 Move Find into Model
Move a find into the model to clean up the controllers and remove duplication. Also see how you can call these custom find methods through an association.[code="java"]# tasks_controller.rbdef ...原创 2008-12-02 21:27:25 · 84 阅读 · 0 评论 -
#5 Using with_scope
Learn how to use with_scope - a very powerful method which will allow your custom find methods to accept any find options. Just like magic![code="java"]# models/task.rbdef self.find_incomplete(o...原创 2008-12-02 21:28:45 · 70 阅读 · 0 评论 -
#6 Shortcut Blocks with Symbol to_proc
It may have a goofy syntax, but the Symbol#to_proc feature Rails adds allows you to do simple blocks very quickly and easily.[code="java"]# models/task.rbdef self.all_names find(:all).collect...原创 2008-12-02 21:31:32 · 72 阅读 · 0 评论 -
#7 All About Layouts
Everything you wanted to know about layouts: global layouts, controller layouts, shared layouts, dynamic layouts and action layouts. Yes, there really are that many ways to specify a layout.[code="j...原创 2008-12-02 21:36:21 · 68 阅读 · 0 评论 -
#8 Layouts and content_for
If you want to change something in the layout on a per-template basis, content_for is your answer! This allows templates to specify view code that can be placed anywhere in a layout.[code="java"]...原创 2008-12-03 00:21:07 · 82 阅读 · 0 评论 -
#9 Filtering Sensitive Logs
Are you accepting sensitive user data? Passwords, credit card numbers, etc. By default, Rails stores all submitted parameters in plain text in the logs. This episode will show you how to filter this s...原创 2008-12-03 00:23:00 · 59 阅读 · 0 评论 -
#10 Refactoring User Name Part 1
Learn how to clean up your code through refactoring. This episode will show you how to move code from the view into the model to remove duplication and simplify the view.[code="java"]Name: ...原创 2008-12-03 00:28:48 · 80 阅读 · 0 评论 -
#11 Refactoring User Name Part 2
Testing and refactoring go hand in hand. Refactoring is all about improving code without changing its behavior. Testing is all about making sure you don't change the behavior while you are improving t...原创 2008-12-03 00:29:59 · 87 阅读 · 0 评论 -
#12 Refactoring User Name Part 3
In the final part of this series you will see how to refactor your tests. Keeping tests clean is important because it will make testing easier to do in the future.[code="java"]# user_test.rb...原创 2008-12-03 00:32:58 · 82 阅读 · 0 评论 -
#13 Dangers of Model in Session
Be careful when storing a model in a session. It will behave differently than you expect and can easily get out of sync with the database. Instead of storing the model directly in the session, store t...原创 2008-12-03 00:35:10 · 82 阅读 · 0 评论 -
#14 Performing Calculations on Models
Did you know ActiveRecord provides class methods for performing calculations on models? You can even use these methods through associations.[code="java"]Task.sum(:priority)Task.sum(:priority, :c...原创 2008-12-03 00:37:24 · 119 阅读 · 0 评论 -
#15 Fun with Find Conditions
You can pass more than simple strings to find conditions. Arrays, ranges, and nil values can be passed as well. In this episode you will see the tricks involved with passing these odd objects to find ...原创 2008-12-03 09:50:34 · 95 阅读 · 0 评论 -
#16 Virtual Attributes
Keep your controllers clean and forms flexible by adding virtual attributes to your model. This very powerful technique allows you to create form fields which may not directly relate to the database....原创 2008-12-03 09:52:40 · 66 阅读 · 0 评论 -
#17 HABTM Checkboxes
It is often asked: how do I create a list of checkboxes for managing a HABTM association? Ask no more because this episode will show you how to do exactly that.[code="java"] # produ...原创 2008-12-03 12:25:47 · 61 阅读 · 0 评论