- tmux
- zsh
- sideup (操控視窗介面)
- wget (下載用好工具)
- tmuxinator
- tmux-color-solarized (程式編碼配色)
test
- zeus ( preload rails environment )
- spring
- capybara
- rspec-rails
持續新增...
def feed@links = Link.all(:select => "title, url, id, description, updated_at", :order => "updated_at DESC", :limit => 20)respond_to do |format|format.htmlformat.rss { render :layout => false }endend
xml.instruct! :xml, :version => "1.0"xml.rss :version => "2.0" doxml.channel doxml.title "learn rails"xml.description "study"xml.link links_urlfor link in @linksxml.item doxml.id link.idxml.title link.titlexml.description link.descriptionxml.pubDate link.updated_at.to_s(:rfc822)xml.link link.urlendendendend
<%= link_to("rss" , feed_links_path(rss))%>
gem 'acts_as_commentable'
rails g comment
rake db:migrate
class CommentsController < ApplicationControllerdef create@link = Link.find(params[:link_id])comment = Comment.new( :title => "", :comment => params[:comment][:comment])if current_user != nilcomment.user_id = current_user.idendlogger << params[:comment]@link.add_comment commentredirect_to root_pathendend
:comment => params[:comment][:comment]) 這邊這樣用是因為 view 用simple_form_for 後來帶過來的是 comment={comment={msg}} 之後再研究看看正常寫法
<%= simple_form_for(@comment, :url => comments_path(@comment, :link_id => link )) do |f| %><div><%= f.input :comment , :label => "--" %><%= f.button :submit , :class => "btn btn-info"%></div><% end %>
gem install embedly
def create
@link = current_user.links.build(link_params)
@link.save
redirect_to root_path
end
private
def link_params
params.require(:link).permit(:url,:user_id)
end
class Link < ActiveRecord::Base belongs_to :user after_create :update_from_embedly def update_from_embedly link = self embedly_api = Embedly::API.new(:key => Setting.embedly_key) embedly_objs = embedly_api.oembed :url => link.url embedly_obj = embedly_objs[0] response_data = embedly_obj.marshal_dump link.title = response_data[:title] link.link_type = response_data[:type] link.provider_name = response_data[:provider_name] link.provider_url = response_data[:provider_url] link.description = response_data[:description] link.thumbnail_url = response_data[:thumbnail_url] link.thumbnail_width = response_data[:thumbnail_width] link.thumbnail_height = response_data[:thumbnail_height] link.save end end