将长URL转换为show scaffold上的Ruby on Rails数据库中的Bit.ly URL

时间:2012-04-19 06:40:47

标签: ruby-on-rails gem url-shortener bit.ly

我真的是RoR的新手,但我一直认为学习语言的最佳方法是先跳进去。我正在创建一个在RoR中生成webapp的报告。 到目前为止我的进展:

  

rails new Project

     

cd Project

     

rails生成脚手架数据库League_Name:string Logo_URL:string Event_URL:string Website:string Facebook:string Twitter:string Youtube:string Funding:string Owner:string Phone:string Email:string Other:string Attendence:string Events_per_Year:string Locations :string规则:字符串How_to_Enter:string Notable_Streamers:string Event_Titles:string背景:文本game1_title:string game1_genre:string game1_years_played:string game1_prize_pool:string game1_prize_awarded:string game1_live:string game1_transmitted:string game1_method:string game1_advance_entry:string game1_invitational:string game1_contestants_open:string game1_bracket_finals:string game1_bracket_finals:string game1_rules:text game2_title:string game2_genre:string game2_years_played:string game2_prize_pool:string game2_prize_awarded:string game2_live:string game2_transmitted:string game2_method:string game2_advance_entry:string game2_invitational:st环game2_contestants_open:字符串game2_contestants_finals:字符串game2_bracket_open:字符串game2_bracket_finals:字符串game2_rules:文本game3_title:字符串game3_genre:字符串game3_website:字符串game3_years_played:字符串game3_prize_pool:字符串game3_prize_awarded:字符串game3_live:字符串game3_transmitted:字符串game3_method:字符串game3_advance_entry:字符串game3_invitational:字符串game3_contestants_open :string game3_contestants_finals:string game3_bracket_open:string game3_rules:text game4_title:string game4_genre:string game4_years_played:string game4_prize_pool:string game4_prize_awarded:string game4_live:string game4_transmitted:string game4_method:string game4_advance_entry:string game4_invitational:string game4_contestants_open:string game4_contestants_finals:string game4_bracket_open:string game4_bracket_finals:string game4_rules:text

     

rake db:migrate

我已经在show scaffold上进行了一些CSS重新格式化,这部分很顺利。从长远来看,我想输入我的所有数据,当我点击show时它会返回这样的内容:

https://docs.google.com/spreadsheet/ccc?key=0AsOtsP63Kb2mdFpKZFZ6OV9PQmVWUU9Qc1FzV2UtVGc

所有这一切都很好;然而,有时网站facebook twitter等的URL比< TD>将允许我的格式和文本只是落后。我做了一些搜索,我发现有一些网站说可以使用有点服务创建一个较短的URL。对于初学者来说,这些网站非常模糊。

http://coryschires.com/how-to-shorten-urls-with-bit-ly-in-ruby-on-rails/

似乎我想要的是正确的轨道,但我不知道如何制作

<tr>
<td class="td1">Website:</td>
<td><%= @database.Website %></td>
</tr>
<tr>
<td class="td1">Facebook:</td>
<td><%= @database.Facebook %></td>
</tr>
<tr>
<td class="td1">Twitter:</td>
<td><%= @database.Twitter %></td>
</tr>
<tr>
<td class="td1">Youtube:</td>
<td><%= @database.Youtube %></td>
</tr>

产生一个URL的bit.ly版本。我不明白如何在我的工作中实施他的榜样。

0 个答案:

没有答案