我正在使用Rails 6.0.3.2, ruby 2.7.1, yarn 1.22.0。
我正在尝试做正常的UJS事情,这是我遇到的错误:
VM125:1 Uncaught ReferenceError: $ is not defined
at <anonymous>:1:1
at processResponse (rails-ujs.js:283)
at rails-ujs.js:196
at XMLHttpRequest.xhr.onreadystatechange (rails-ujs.js:264)
Run Code Online (Sandbox Code Playgroud)
这是我的package.json:
{
"name": "myapp",
"private": true,
"dependencies": {
"@rails/actioncable": "^6.0.0",
"@rails/actiontext": "^6.0.2-2",
"@rails/activestorage": "^6.0.0",
"@rails/ujs": "^6.0.0",
"@rails/webpacker": "4.2.2",
"bootstrap": "^4.4.1",
"data-confirm-modal": "^1.6.2",
"expose-loader": "^1.0.0",
"flickity": "^2.2.1",
"jquery": "3.4.1",
"local-time": "^2.1.0",
"popper.js": "^1.16.1",
"stimulus": "^1.1.1",
"trix": "^1.0.0",
"turbolinks": "^5.2.0"
},
"version": "0.1.0",
"devDependencies": {
"webpack-dev-server": "^3.10.3"
}
}
Run Code Online (Sandbox Code Playgroud)
这是我的 …
你可以在这里看到实现:
在Mac上的FireFox中,该圆圈是圆形/实心的.我想要它破折或点缀.
甚至更奇怪的是,相同的属性(即border: 4px dashed #000)在HR上工作正常.那么为什么在涉及border-radius时它不起作用?
这对我来说太奇怪了.
在我看来,我有这个:
<%
@plan = Plan.limit(4).all
plan ||= Plan.find(params[:plan_id])
%>
<%= select_tag "Plan", options_from_collection_for_select(@plan, 'id', 'name', plan.id) %><br />
Run Code Online (Sandbox Code Playgroud)
这产生以下结果:
<select id="Plan" name="Plan"><option value="1">Gecko</option>
<option value="2" selected="selected">Iguana</option>
</select>
Run Code Online (Sandbox Code Playgroud)
但是,我希望它能够产生以下选项:
<select id="Plan" name="Plan"><option value="1">Gecko ($50)</option>
<option value="2" selected="selected">Iguana ($99)</option>
</select>
Run Code Online (Sandbox Code Playgroud)
括号中的价格是plan.amount.
我有一个collection_select:
<%= form_for(@feedback) do |f| %>
<div class="field">
<%= f.label :poster_id %><br />
<%= f.collection_select :feedback, :poster_id, @users, :id, @user.username, :prompt => "Select your username" %><br />
<%= f.number_field :poster_id %>
</div>
<% end %>
Run Code Online (Sandbox Code Playgroud)
这是错误消息:
ActionView::Template::Error (undefined method `merge' for "test":String):
15:
16: <div class="field">
17: <%= f.label :poster_id %><br />
18: <%= f.collection_select :feedback, :poster_id, @users, :id, @user.username %><br />
19: <%= f.number_field :poster_id %>
20: </div>
21: <div class="field">
app/views/feedbacks/_form.html.erb:18:in `block in _app_views_feedbacks__form_html_erb__3181571289116259961_2154876620'
app/views/feedbacks/_form.html.erb:3:in `_app_views_feedbacks__form_html_erb__3181571289116259961_2154876620'
Run Code Online (Sandbox Code Playgroud)
"test"是返回的用户名@user.username …
所以我在我的Rails应用程序中包含了样式表的URL ,但它将所有内容都抛入了haywire.
我把它包括在内:
<%= stylesheet_link_tag('http://twitter.github.com/bootstrap/1.4.0/bootstrap.min.css', 'style', 'css3buttons', 'jquery.lightbox-0.5', :media => 'all') %>
Run Code Online (Sandbox Code Playgroud)
我想要做的是,当我将类应用于html标签时,应用Twitter样式.理想情况下,我想要做的是让它甚至覆盖我的"样式"表中的样式 - 这是我整个应用程序的样式表.
是否有可能以简单的方式完成此操作,而无需为我想要使用的每个元素修改样式?
在命令行,如果我这样做mate <filepath>,在TextMate中为我打开正确的文件.
但当我这样做时:
$ mate -v
open: invalid option -- v
Usage: open [-e] [-t] [-f] [-W] [-R] [-n] [-g] [-h] [-b <bundle identifier>] [-a <application>] [filenames] [--args arguments]
Run Code Online (Sandbox Code Playgroud)
另外,当我这样做时git commit,我看到了这个:
$ git commit
error: cannot run mate: No such file or directory
error: There was a problem with the editor 'mate'.
Please supply the message using either -m or -F option.
Run Code Online (Sandbox Code Playgroud)
我~/.bashprofile有以下几点:
#Set Textmate as my default editor from the command-line
alias mate='open …Run Code Online (Sandbox Code Playgroud) 我正在尝试运行此迁移:
class RemoveClientFromSalesteam < ActiveRecord::Migration
change_table :sales_teams do |t|
t.remove :client_id
end
end
Run Code Online (Sandbox Code Playgroud)
这是我得到的错误:
rake db:migrate
-- change_table(:sales_teams)
rake aborted!
An error has occurred, this and all later migrations canceled:
Index name 'temp_index_altered_sales_teams_on_client_priority_and_personal_priority' on table 'altered_sales_teams' is too long; the limit is 64 characters
Tasks: TOP => db:migrate
(See full trace by running task with --trace)
Run Code Online (Sandbox Code Playgroud)
这就是我的schema.rb样子:
create_table "sales_teams", :force => true do |t|
t.string "name"
t.integer "firm_id"
t.boolean "client_priority"
t.boolean "personal_priority"
t.datetime "created_at", :null => false
t.datetime …Run Code Online (Sandbox Code Playgroud) 我有一个模型(Listing),它有很多很多属性(比如说25).
我想基于表单中的输入创建一个动态的AJAX表单.
这意味着如果用户选择type=b,他们将看到他们应该看到的其他字段而不是他们不应该看到的字段.
理想情况下,他们应该使用db中的正确内容立即加载 - 即以AJAXy方式加载.
什么是最好的方法来解决这个问题?
谢谢.
编辑:这是我的一个例子_form.html.erb.您会注意到我已经包含了2个if语句,这些语句指示如果property_type选择的值是指定值之一,哪些字段应该显示:
<%= simple_form_for(@listing) do |f| %>
<%= f.error_notification %>
<div class="form-inputs">
<%= f.input :headline %>
<%= f.input :price %>
<%= f.association :property_type %>
If property_type == "coop"
<%= f.input :maintenance %>
<%= f.input :coop_deductible %>
<%= f.input :flip_tax %>
if property_type == "condo"
<%= f.input :common_charges %>
<%= f.input :taxes %>
</div>
<div class="form-actions">
<%= f.button :submit %>
</div>
<% end %> …Run Code Online (Sandbox Code Playgroud) 我安装了RMagick并在OS X Mountain Lion中完美运行.我刚刚安装了OS X Mavericks,当我尝试运行时rails s,我收到此错误:
/.rvm/gems/ruby-2.0.0-p0@myapp/gems/activesupport-3.2.14/lib/active_support/dependencies.rb:251:in `require': dlopen(/.rvm/gems/ruby-2.0.0-p0@myapp/gems/rmagick-2.13.2/lib/RMagick2.bundle, 9): Library not loaded: /usr/lib/libltdl.7.dylib (LoadError)
Referenced from: /.rvm/gems/ruby-2.0.0-p0@myapp/gems/rmagick-2.13.2/lib/RMagick2.bundle
Reason: image not found - /.rvm/gems/ruby-2.0.0-p0@myapp/gems/rmagick-2.13.2/lib/RMagick2.bundle
from /.rvm/gems/ruby-2.0.0-p0@myapp/gems/activesupport-3.2.14/lib/active_support/dependencies.rb:251:in `block in require'
from /.rvm/gems/ruby-2.0.0-p0@myapp/gems/activesupport-3.2.14/lib/active_support/dependencies.rb:236:in `load_dependency'
from /.rvm/gems/ruby-2.0.0-p0@myapp/gems/activesupport-3.2.14/lib/active_support/dependencies.rb:251:in `require'
from /.rvm/gems/ruby-2.0.0-p0@myapp/gems/rmagick-2.13.2/lib/rmagick.rb:11:in `<top (required)>'
from /.rvm/gems/ruby-2.0.0-p0@global/gems/bundler-1.3.2/lib/bundler/runtime.rb:72:in `require'
from /.rvm/gems/ruby-2.0.0-p0@global/gems/bundler-1.3.2/lib/bundler/runtime.rb:72:in `block (2 levels) in require'
from /.rvm/gems/ruby-2.0.0-p0@global/gems/bundler-1.3.2/lib/bundler/runtime.rb:70:in `each'
from /.rvm/gems/ruby-2.0.0-p0@global/gems/bundler-1.3.2/lib/bundler/runtime.rb:70:in `block in require'
from /.rvm/gems/ruby-2.0.0-p0@global/gems/bundler-1.3.2/lib/bundler/runtime.rb:59:in `each'
from /.rvm/gems/ruby-2.0.0-p0@global/gems/bundler-1.3.2/lib/bundler/runtime.rb:59:in `require'
from /.rvm/gems/ruby-2.0.0-p0@global/gems/bundler-1.3.2/lib/bundler.rb:132:in `require'
from /myapp/config/application.rb:13:in `<top (required)>'
from /.rvm/gems/ruby-2.0.0-p0@myapp/gems/railties-3.2.14/lib/rails/commands.rb:53:in `require'
from /.rvm/gems/ruby-2.0.0-p0@myapp/gems/railties-3.2.14/lib/rails/commands.rb:53:in `block in …Run Code Online (Sandbox Code Playgroud) 当我这样做时git status,我看到的是:
$ git status
# On branch master
# Your branch is ahead of 'github/master' by 1 commit.
# (use "git push" to publish your local commits)
#
# Changes not staged for commit:
# (use "git add <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
# (commit or discard the untracked or modified content in submodules)
#
# modified: octopress (modified content, untracked content)
# …Run Code Online (Sandbox Code Playgroud)