我有需要更改的迁移(创建回来),如下所示:
20130923000732_create_questions.rb
Run Code Online (Sandbox Code Playgroud)
我需要改变
t.string to --> t.text
Run Code Online (Sandbox Code Playgroud)
我怎么能实现这个目标?
我读到我可以创建一个新的迁移重命名列,但我不太明白.
当时我使用2个Mixins作为我的Border Radius:
// When the Input is 1 Variable
@mixin border-radius($pixel) {
border-radius: $pixel;
}
// When the Inputs are 4 Variables
@mixin border-radius-s($tl, $tr, $br, $bl) {
border-top-left-radius: $tl;
border-top-right-radius: $tr;
border-bottom-right-radius: $br;
border-bottom-left-radius: $bl;
}
Run Code Online (Sandbox Code Playgroud)
我正试图找到一种方法将这些mixin合二为一!可能有一个if else输入.我已经尝试过,但找不到任何好的工作解决方案.
任何可以帮助我的人?
我正试图通过Redcarpet工作来获得Syntax Highlighting
我的appliaction_helper.rb:
module ApplicationHelper
def markdown(text)
render_options = {
# will remove from the output HTML tags inputted by user
filter_html: true,
# will insert <br /> tags in paragraphs where are newlines
hard_wrap: true,
# hash for extra link options, for example 'nofollow'
link_attributes: { rel: 'nofollow' },
# Prettify
prettify: true
}
renderer = Redcarpet::Render::HTML.new(render_options)
extensions = {
#will parse links without need of enclosing them
autolink: true,
# blocks delimited with 3 …Run Code Online (Sandbox Code Playgroud) 我正在尝试对一个协会进行分页,但我错过了一些东西.
这是我需要分页的地方.paginate(:page => params[:page], :per_page => 25).如果我理解正确,我必须在我的控制器中创建一个变量来取城镇?
<% @alliance.players.each do |p| %>
<% p.towns.each do |t| %>
...
<% end %>
<% end %>
Run Code Online (Sandbox Code Playgroud)
我在说什么:
Alliance ->
Players ->
Towns <--
Run Code Online (Sandbox Code Playgroud)
基本上我坚持如何在二级循环中对关联进行分页.
也许有更好的方法来做到这一点.
协会:
class Alliance < ActiveRecord::Base
# Primary Key
self.primary_key = 'grepo_id'
# Associations
has_many :players
end
class Player < ActiveRecord::Base
# Primary Key
self.primary_key = 'grepo_id'
# Associations
has_many :towns
belongs_to :alliance
end
class Town < ActiveRecord::Base
# Primary Key
self.primary_key = 'grepo_id'
# Associations …Run Code Online (Sandbox Code Playgroud) 我正在尝试将我的Tmux前缀绑定到Space- w但似乎无法取消绑定C前缀.
那就是我被困住的地方
unbind C-b
set -g prefix C-Space
bind Space send-prefix
Run Code Online (Sandbox Code Playgroud)
如何将前缀绑定到Space-w
我正在尝试在链接上的标题标记中包含变量.
例如
<%= link_to @user.facebook_link, title: "Facebook" %>
Run Code Online (Sandbox Code Playgroud)
所以它看起来像这样:
<%= link_to @user.facebook_link, title: "<% @user.name %> on Facebook", target: '_blank' do %>
Run Code Online (Sandbox Code Playgroud)
我怎样才能做到这一点?
我谷歌周围并尝试了很多东西,但我没有做对.
我正在使用Rails 4并且通常对rails很新.
有人可以向我解释,(似乎看起来),在Heroku上设置自定义错误页面的基本步骤?
谢谢
error-handling controller ruby-on-rails heroku ruby-on-rails-4
用户可以在屏幕上发表评论,并由PublicActivity跟踪:
@comment.create_activity :create, owner: current_user, recipient: @comment.screen.user
Run Code Online (Sandbox Code Playgroud)
并且注释依赖于::在屏幕模型上销毁.
但是当我删除屏幕时,删除注释时,该注释的PublicActivity记录仍然存在.
这是我的Screens Controller:
def destroy
@activity = PublicActivity::Activity.find_by_trackable_id(params[:id])
@activity.destroy #<-- Heres the Problem
@screen.destroy
respond_to do |format|
format.html { redirect_to root_path }
format.json { head :no_content }
end
end
Run Code Online (Sandbox Code Playgroud)
但是在删除屏幕后,我正在undefined method为'nil:NilClass`进行破坏.
我在Railscast上读到:
这是因为在对象被销毁之后调用了create_activity方法.
根据gem维护者的说法,你只需假设记录将被销毁,并在销毁之前调用create_activity
我错过了什么?
以下信息
screen.rb
belongs_to :user
has_many :comments, :dependent => :destroy
Run Code Online (Sandbox Code Playgroud)
comment.rb
belongs_to :user
belongs_to :screen
Run Code Online (Sandbox Code Playgroud)
screens_contoller.rb
def create
@screen = current_user.screens.build(screen_params)
respond_to do |format|
if @screen.save
format.html { redirect_to @screen, notice: 'You successfully uploaded …Run Code Online (Sandbox Code Playgroud) 我试图让我的:before箭与我的工作很好div,但我找不到给箭头的方法
background-color: transparent dashed border.
CSS:
position: absolute;
top: 30px;
right: 8px;
display: inline-block;
border-top: 12px dashed transparent;
border-left: 12px dashed #b3b3b3;
border-bottom: 12px dashed transparent;
border-left-color: #b3b3b3;
content: '';
Run Code Online (Sandbox Code Playgroud)
我正试图让'类似Twitter的'验证工作.这意味着
- Only alphanumeric and not all numeric
Run Code Online (Sandbox Code Playgroud)
但我坚持正则表达式.有人可以用特定的正则表达式帮助我吗?
validates :user_name, with: 'elmagicoregexp'
我有两个与Glyphicons的链接,想要Text-decoration:none; 但由于某种原因,它不会消失,我总是一个悬停线.
链接是:
<p class="user-profile-social-links pull-right">
<% if @user.facebooklink.present? %>
<%= link_to @user.facebooklink, title: "Facebook", :target => '_blank' do %>
<i class="icon-facebook-sign"></i>
<% end %>
<% end %>
<% if @user.twitterlink.present? %>
<%= link_to @user.twitterlink, title: "Twitter", :target => '_blank' do %>
<i class="icon-twitter-sign"></i>
<% end %>
<% end %>
</p>
Run Code Online (Sandbox Code Playgroud)
这个类有这个CSS:
.user-profile-social-links {
text-decoration: none;
display: block;
color: #777;
}
Run Code Online (Sandbox Code Playgroud)
难道我做错了什么 ?为什么不工作?
*编辑:* 这是我仍然得到的 - > http://imgur.com/raC362u(稍微放大以查看图标下方的线条)
我有很多主要类别,并希望添加到每个子类别.->
主要类别
- 子类别
- 子类别
- 子类别
主要类别
- 子类别
- 子类别
- 子类别
很多人建议我使用宝石,但由于我对Rails相当陌生,我宁愿自己学习如何做到这一点,也要学习他们所有的方法.
我应该从一个Scaffold或简单的开始Model吗?
有人可以解释我如何开始(迁移等)以及如何设置它?
谢谢.
migration ruby-on-rails categories ruby-on-rails-3 ruby-on-rails-4
css ×3
ruby ×3
css3 ×2
html ×2
migration ×2
associations ×1
categories ×1
controller ×1
heroku ×1
hyperlink ×1
methods ×1
mixins ×1
redcarpet ×1
rollback ×1
sass ×1
tmux ×1
tmuxinator ×1
validation ×1