首先,我知道这里已经列出了这个错误,但问题是不同的。
我有一个 Rails 4 应用程序,我曾经在 Puma 上运行过。
然后,我的一个朋友开发了该应用程序,并建议我们改用 Foreman。
所以,我曾经rails s在终端中在本地运行该应用程序。
现在,我应该用foreman start.
问题是,几乎每次我尝试启动该应用程序时,都会出现以下错误:
foreman start
08:42:28 web.1 | started with pid 3398
08:42:28 web.1 | [3398] Puma starting in cluster mode...
08:42:28 web.1 | [3398] * Version 2.13.4 (ruby 2.2.1-p85), codename: A Midsummer Code's Dream
08:42:28 web.1 | [3398] * Min threads: 5, max threads: 5
08:42:28 web.1 | [3398] * Environment: development
08:42:28 web.1 | [3398] * Process workers: 2
08:42:28 web.1 …Run Code Online (Sandbox Code Playgroud) 这是_header.html.erb我们的Rails 4应用程序,使用Bootstrap 3组件制作:
<header class="navbar navbar-fixed-top navbar-inverse">
<div class="container">
<nav>
<div class="col-xs-4">
<%= link_to "APP NAME", root_path, id: "logo" %>
</div>
<div class="col-xs-4 text-center">
<ul class="nav navbar-nav navbar-center">
<li><%= link_to "Features", features_path %></li>
<li><%= link_to "Pricing", pricing_path %></li>
<li><%= link_to "Blog", '#' %></li>
</ul>
</div>
<div class="col-xs-4">
<ul class="nav navbar-nav navbar-right">
<% if current_user.try(:admin?) %>
<li><%= link_to "Users", users_path %></li>
<% end %>
<% if logged_in? %>
<li><%= link_to "Dashboard", current_user %></li>
<li><%= link_to "Settings", current_user %></li>
<li><%= …Run Code Online (Sandbox Code Playgroud) ruby-on-rails conditional-statements navbar twitter-bootstrap ruby-on-rails-4
我有一个 Rails 4 应用程序,它使用 Rails 的默认表单(我没有使用简单表单)。
我的一个表单允许用户上传图像(感谢 Paperclip):
<td>
<%= f.file_field :image, value: "Choose a file" %>
</td>
Run Code Online (Sandbox Code Playgroud)
我想使用自定义 CSS 设置“选择文件按钮”的样式。
我尝试将 anid应用于我的 td,如下所示:
<td id="upload_image">
<%= f.file_field :image, value: "Choose a file" %>
</td>
Run Code Online (Sandbox Code Playgroud)
然后我尝试使用以下 CSS 代码对其进行样式设置:
#upload_image input {
background-color: #2c3e50;
background-image: none;
border: none;
color: #FFF;
padding: 5px 10px 5px 10px;
}
Run Code Online (Sandbox Code Playgroud)
但这导致了样式td本身:
我仍然得到这个带有默认样式的丑陋按钮。
————
更新:如果无法对按钮本身进行样式设置,我想至少将“未选择文件”标签(法语中的“aucun fichier choisi”)放在按钮下方,因为目前它占用了很多水平空间在我的页面上)。
这甚至可能吗?
————
我怎样才能使这项工作?
为了以更高效的方式使用Golang进行编程,我刚刚为Sublime Text 2安装了GoSublime,正如其官方GitHub存储库中所述:
安装
Sublime Package Control允许您从编辑器中轻松安装或删除GoSublime(和许多其他ST2包).它还提供自动更新包,因此您不再需要跟踪GoSublime中的更改.
从http://wbond.net/sublime_packages/package_control安装Sublime Package Control(如果你还没有这样做) .
请务必重新启动ST2以完成安装.
打开命令调色板(默认
ctrl+shift+p或cmd+shift+p)并开始键入Package Control: Install Package然后按返回或单击该选项以激活它.您将看到一个新的快速面板,其中包含可用包的列表.键入GoSublime并按回车或在其条目上安装GoSublime.如果GoSublime没有条目,您很可能已经安装了它.
现在,每当我启动Sublime Text时,我都会收到以下错误消息:
MarGo: Missing required environment variables: GOPATH
See the `Quirks` section of USAGE.md for info
Run Code Online (Sandbox Code Playgroud)
并usage.md自动打开一个文件,其中包含以下内容:
Usage
=====
Note
----
* Unless otherwise mentioned, `super` replaces `ctrl` in key bindings on OS X.
* A mention of a (GO)PATH variable uses a colon(`:`) as the separator.
This is the …Run Code Online (Sandbox Code Playgroud) 我关注的是Fernando Villalobos的React.js - Rails开发人员 AirPair教程的指南.
这里的目标是使用Rails和React JS构建一个简单的费用跟踪应用程序.
在" 嵌套组件:列表记录"部分中,作者建议app/views/records/index.html.erb按如下方式创建文件:
<%# app/views/records/index.html.erb %>
<%= react_component 'Records', { data: @records } %>
Run Code Online (Sandbox Code Playgroud)
和一个javascripts/components/records.js.coffee文件如下:
# app/assets/javascripts/components/records.js.coffee
@Records = React.createClass
render: ->
React.DOM.div
className: 'records'
React.DOM.h2
className: 'title'
'Records'
Run Code Online (Sandbox Code Playgroud)
然后,当我们访问时localhost:3000/records,我们应该看到以下内容:
但是,当我访问时localhost:3000/records,我收到以下错误:
ExecJS::RuntimeError in Records#index
SyntaxError: [stdin]:7:10: cannot have an implicit value in an implicit object
<title>Expenses</title>
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
<%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
<%= csrf_meta_tags …Run Code Online (Sandbox Code Playgroud) 我做了一些研究,发现这个问题已经在不同的地方多次解决了:
我尝试按照上面链接中给出的示例进行操作,并在我的routes.rb文件中提出了以下解决方案:
root to: 'pages#home'
devise_for :users, :path => 'account', controllers: { registrations: "registrations", confirmations: "confirmations" }
authenticated :user do
root 'calendars#index', as: :authenticated_root
end
Run Code Online (Sandbox Code Playgroud)
这里的目标是将unauthenticated用户引导到home网站的常规页面,而authenticated用户将转到他们的仪表板,在应用程序内,即calendars#index路线,在我的路线中定义如下:
calendars GET /calendars(.:format) calendars#index
Run Code Online (Sandbox Code Playgroud)
但是,当我以用户身份登录并访问 时http://localhost:3000/,我一直登陆home网站的常规页面,而不是应用程序内的用户仪表板。
我究竟做错了什么?
authentication ruby-on-rails rails-routing devise ruby-on-rails-4
React的网站声明:
很多人使用React作为MVC中的V.
由此,我推断React不会在MVC中扮演"M"和"C"角色.
如果这是正确的,则意味着无法仅使用React JS构建整个Web应用程序.
那怎么样?
model-view-controller frameworks web-applications reactjs reactjs-flux
继Tony Coconate的Rails + Ember.js(使用Ember CLI)教程之后,我们正在尝试创建一个新的Rails API.
当我们运行时rails new api -T -d postgresql,我们收到以下错误消息:
An error occurred while installing pg (0.18.2), and Bundler cannot continue.
Make sure that `gem install pg -v '0.18.2'` succeeds before bundling.
Run Code Online (Sandbox Code Playgroud)
这是Gemfile文件的样子:
source "https://rubygems.org"
gem "rails", "4.2.1"
gem "activeadmin", github: "gregbell/active_admin" # Until it"s 1.0.0
gem "coffee-rails", "~> 4.0.0"
gem "devise"
gem "grape"
gem "grape-active_model_serializers"
gem "grape-swagger-rails"
gem "jquery-rails"
gem "pg"
gem "rack-cors", require: "rack/cors"
gem "sass-rails", "~> 4.0.3"
gem "uglifier", …Run Code Online (Sandbox Code Playgroud) 在Golang官方网站的"入门"部分,我们读到:
安装Go工具
如果要从较早版本的Go升级,则必须先删除现有版本.
Linux,Mac OS X和FreeBSD tarball
下载存档并将其解压缩到/ usr/local,在其中创建一个Go树
/usr/local/go.例如:
tar -C /usr/local -xzf go$VERSION.$OS-$ARCH.tar.gz选择适合您的安装的存档文件.例如,如果要在Linux上为64位x86安装Go版本1.2.1,则所需的存档称为go1.2.1.linux-amd64.tar.gz.
(通常,这些命令必须以root身份或通过sudo运行.)
添加
/usr/local/go/bin到PATH环境变量.您可以通过将此行添加到您的/etc/profile(用于系统范围的安装)或$HOME/.profile:
export PATH=$PATH:/usr/local/go/bin
当我们访问下载部分时,我们会看到许多选项:
go1.4.2
文件名Kind OS Arch SHA1校验和
go1.4.2.src.tar.gz来源460caac03379f746c473814a65223397e9c9a2f6
go1.4.2.darwin-386-osx10.6.tar.gz存档OS X 10.6+ 32位fb3e6b30f4e1b1be47bbb98d79dd53da8dec24ec
go1.4.2.darwin-386-osx10.8.tar.gz存档OS X 10.8+ 32位65f5610fdb38febd869aeffbd426c83b650bb408
go1.4.2.darwin-386-osx10.6.pkg安装程序OS X 10.6+ 32位3ed569ce33616d5d36f963e5d7cefb55727c8621
go1.4.2.darwin-386-osx10.8.pkg安装程序OS X 10.8+ 32位7f3fb2438fa0212febef13749d8d144934bb1c80
go1.4.2.darwin-amd64-osx10.6.tar.gz存档OS X 10.6+ 64位00c3f9a03daff818b2132ac31d57f054925c60e7
go1.4.2.darwin-amd64-osx10.8.tar.gz存档OS X 10.8+ 64位58a04b3eb9853c75319d9076df6f3ac8b7430f7f
go1.4.2.darwin-amd64-osx10.6.pkg安装程序OS X 10.6+ 64位3fa5455e211a70c0a920abd53cb3093269c5149c
go1.4.2.darwin-amd64-osx10.8.pkg安装程序OS X 10.8+ 64位8fde619d48864cb1c77ddc2a1aec0b7b20406b38
我使用以下配置运行Mac OS X Yosemite,版本10.10.3:
在我最初的 Rails 4 应用程序中,我有以下模型:
User
has_many :administrations
has_many :calendars, through: :administrations
has_many :comments
Calendar
has_many :administrations
has_many :users, through: :administrations
has_many :posts
has_many :comments, through: :posts
Administration
belongs_to :user
belongs_to :calendar
Post
belongs_to :calendar
has_many :comments
Comment
belongs_to :post
belongs_to :user
Run Code Online (Sandbox Code Playgroud)
我刚刚向Ad应用程序添加了一个新模型:
Ad
belongs_to :calendar
Run Code Online (Sandbox Code Playgroud)
现在我想允许用户写关于广告记录的评论。
我可以使用我现有的Comment模型并执行以下操作:
Ad
belongs_to :calendar
has_many :comments
Comment
belongs_to :post
belongs_to :user
Run Code Online (Sandbox Code Playgroud)
或者我是否需要创建一个独特的“评论”模型,例如我会调用它AdComments还是Feedback?
model-view-controller activerecord ruby-on-rails relational-database ruby-on-rails-4
go ×2
macos ×2
reactjs ×2
activerecord ×1
coffeescript ×1
css ×1
devise ×1
filefield ×1
foreman ×1
forms ×1
frameworks ×1
gosublime ×1
localhost ×1
navbar ×1
osx-yosemite ×1
postgresql ×1
puma ×1
reactjs-flux ×1
sublimetext2 ×1