小编Ste*_*sch的帖子

在coffescript中声明全局变量

我使用Gem Coocon作为嵌套表格.

#end_date_job_portfolio如果.checkBoxCurrentJob选中,我需要隐藏字段.问题是如果用户没有点击添加新的嵌套表单,jQuery就看不到标签,因为这些标签document还没有.

为此,我使用了cocoon:after-insert.我的脚本:

$(document).ready -> 
  checkbox_date = ""
  end_date = ""
  $('.experiences').on 'cocoon:after-insert', ->
    checkbox_date = $(".checkBoxCurrentJob")
    end_date = $('#end_date_job_portfolio') 
    console.log(checkbox_date)



  #show it when the checkbox is clicked
  ?heckbox_date.on 'click', ->
    console.log("la la la")
    if checkbox_date.prop('checked')
      checkbox_date.hide()
    else
      checkbox_date.fadeIn()
    return 
Run Code Online (Sandbox Code Playgroud)

它显示ReferenceError: \u0441heckbox_date is not defined错误.如何将click checkbox_dateend_date值传递cocoon:after-insert给click事件checkbox_date

javascript ruby-on-rails coffeescript

7
推荐指数
1
解决办法
167
查看次数

Webpack error bundle.js:1 Uncaught SyntaxError:意外的令牌<

我运行服务器localhost并获取错误bundle.js:1 Uncaught SyntaxError:意外的令牌< 输出bundle.js是index.html文件的html代码.这是设置我的webpack.config文件.你能告诉我设置有什么问题吗?

import path from 'path';
import webpack from 'webpack';

export default {
  devtool: 'eval-source-map',
  entry: [
    'webpack-hot-middleware/client',
    path.join(__dirname, '/client/index.js' )
    ],
  output: {
    path: '/',
    publicPath: '/'
  },
  plugins: [
    new webpack.NoEmitOnErrorsPlugin(),
    new webpack.optimize.OccurrenceOrderPlugin(),
    new webpack.HotModuleReplacementPlugin()
  ],
  module: {
    loaders: [
      {
        test: /\.js$/,
        include: path.join(__dirname, 'client'),
        loaders: ['react-hot-loader', 'babel-loader' ]
      }
    ]
  },
  resolve: {
    extensions: ['.js']
  }    
}
Run Code Online (Sandbox Code Playgroud)

的index.html

<html>

 <head>
   <meta charset="UTF-8">
   <title>Site</title>
   <meta content="width=device-width, initial-scale=1" name="viewport" />
 </head>

 <body>
   <h1>Hello bla bla …
Run Code Online (Sandbox Code Playgroud)

javascript node.js webpack

6
推荐指数
2
解决办法
2万
查看次数

PHP 与 Nginx - 403 Forbidden

我想用 nginx 运行项目 yii2(高级模板)。我将 virtualbox 与 vagrant 一起使用(ubuntu 16.04,php 5.6)

我有以下设置nginx文件

//

vhost1.conf
server {
   listen                *:80;

   server_name  frontend.test;
   client_max_body_size 128m;

   root /var/www/frontend/web/;
     index index.php;

   access_log            /var/log/nginx/vhost1.access.log;
   error_log             /var/log/nginx/vhost1.error.log;
   location / {
     try_files $uri $uri/ /index.php$is_args$args;
   }

   location ~ ^/assets/.*\.php$ {
       deny all;
   }

   location ~ \.php$ {
     include fastcgi_params;
     fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
     fastcgi_pass 127.0.0.1:9000;
     #fastcgi_pass unix:/var/run/php5-fpm.sock;
     try_files $uri =404;
   }

   location ~* /\. {
     deny all;
   }
 }
Run Code Online (Sandbox Code Playgroud)

我有以下结构项目的许可:

vagrant@machine1]-[/var/www]-[git master] 
$ ls -la frontend/
total 68
drwxrwxr-x 1 …
Run Code Online (Sandbox Code Playgroud)

php nginx yii yii2 yii2-advanced-app

4
推荐指数
1
解决办法
1万
查看次数

Capybara:测试页面创建对象的当前路径

创建新对象后应重定向到动作节目.我如何检查当前路径?

feature 'add lost pet' do
  given(:data) {attributes_for(:lost_pet)}

  background do
    visit  root_path
    click_on 'Register new lost pet'
  end

  scenario 'add new lost pet with valid data' do
    within '#new_lost_pet' do
      fill_in 'Name', with: data[:name]
      fill_in 'Type', with: data[:type]
      fill_in 'Breed', with: data[:breed]
      fill_in 'Gender', with: data[:gender]
      fill_in 'Size', with: data[:size]
      fill_in 'Colour', with: data[:colour]
      fill_in 'Age', with: data[:age]
      fill_in 'Age unit', with: data[:age_unit]
      fill_in 'Description', with: data[:description]
      fill_in 'Collar description', with: data[:collar_description]
      check 'Desexed', :checked
      check 'Microchipped', :checked
      fill_in 'Microchip …
Run Code Online (Sandbox Code Playgroud)

rspec ruby-on-rails capybara

3
推荐指数
2
解决办法
7566
查看次数

如何使用资产管道在元素div中添加style ="background-image?

在文件夹中assets/images/default/user我存储了一个图像banner.png.

如何直接在下面添加此图像background-image

<div class="banner-img" style="background-image: url('/assets/default/users/banner.png');"></div>
Run Code Online (Sandbox Code Playgroud)

ruby-on-rails

3
推荐指数
1
解决办法
2407
查看次数

HAML - 错误意外的keyword_ensure,期望输入结束

语法haml有什么问题?我用了2个空格.显示错误:/home/user/myapp/bds/app/views/polls/_voting_form.html.haml:14:语法错误,意外的keyword_ensure,期望输入结束

= form_tag votes_path, method: :post, remote: true, id: 'voting_form'
  = hidden_field_tag 'poll[id]', @poll.id

  = render partial: 'polls/poll_item', collection: @poll.poll_items, as: :item  

  %p 
    %b ????? ???????: = @poll.votes_count

  - if current_user.voted_for?(@poll)
    %p ?? ??? ??????????!
  - else
    = submit_tag '??????????', class: 'btn-bg'
Run Code Online (Sandbox Code Playgroud)

haml ruby-on-rails

2
推荐指数
1
解决办法
1639
查看次数

回形针::错误:: MissingRequiredValidatorError

对不起,但我无法找到适合我情况的解决方案

我有下一个代码:

class Document < ActiveRecord::Base
    has_attached_file :item,
                 content_type: { content_type: ["image/jpeg",    "image/gif", "document/pdf"] } 
end
Run Code Online (Sandbox Code Playgroud)

的Gemfile:

source 'https://rubygems.org'


# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.1'
# Use sqlite3 as the database for Active Record
gem 'sqlite3'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.1.0'
# See https://github.com/rails/execjs#readme for more …
Run Code Online (Sandbox Code Playgroud)

ruby-on-rails paperclip

2
推荐指数
1
解决办法
2710
查看次数

如何在DateTime变量中添加1个月?

我有一个订阅模型.在我的订阅表中,我有一个名为的DateTime列expires_at.

例如:

expires_at: "2013-07-03 08:00:26"
Run Code Online (Sandbox Code Playgroud)

我需要再增加30天.我需要使用哪种方法?

ruby ruby-on-rails

2
推荐指数
1
解决办法
3488
查看次数

如何运行文件夹种子中的所有文件?

我有文件夹db/seeds,其中包含大约20个带有项目默认值的文件.

为运行命令rake db:seed提供正确的设置以加载所有这些文件.

ruby-on-rails

2
推荐指数
1
解决办法
953
查看次数

bundle install error之后的错误kernel_require.rb:55:在`require':无法加载这样的文件 - bundler(LoadError)

在远程服务器上我下载了项目.在根目录项目中运行bundle install.显示错误:

/usr/local/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- bundler (LoadError)
    from /usr/local/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /usr/bin/bundle:7:in `<main>'
Run Code Online (Sandbox Code Playgroud)

我检查当前的红宝石版本.是

ruby -v
ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-linux]
Run Code Online (Sandbox Code Playgroud)

我不明白为什么这个错误.但是想想,因为我从没有ruby管理器的机器和手动安装的ruby 2.3.1中删除了rvm.请帮忙.谢谢.

ruby ruby-on-rails

1
推荐指数
1
解决办法
1900
查看次数