小编Ayd*_*kov的帖子

在rails中从mongodb迁移到postgresql

mongo_mapper在Rails中使用MongoDB和gem,项目足够大.有什么办法可以将数据从Mongoid迁移到Postgresql吗?

postgresql ruby-on-rails mongodb mongomapper

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

如何在rails 4中使用mongo_mapper?

我试图使用rails 4.0.0与mongo_mapper 0.12.0并获取该消息

Bundler could not find compatible versions for gem "activesupport":
  In Gemfile:
    mongo_mapper (~> 0.12.0) ruby depends on
      activesupport (~> 3.0) ruby

    rails (= 4.0.0) ruby depends on
      activesupport (4.0.0)
Run Code Online (Sandbox Code Playgroud)

Rails 4和mongo_mapper仍然不兼容?

ruby-on-rails mongodb mongomapper

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

删除上传的图像 rails 4carrierwave

尝试使用carrierwave删除上传的图像

<%= f.fields_for :images do |ff| %>
   <div class="form-group">
      <label>
        <%= ff.check_box :remove_image %>
          <%= image_tag ff.object.image %>
        </label>
      </div>
<% end %>
Run Code Online (Sandbox Code Playgroud)

在控制器中获取此类参数

"images_attributes"=>{"0"=>{"remove_image"=>"0", "id"=>"13"}, "1"=>{"remove_image"=>"1", "id"=>"14"}, "2"=>{"remove_image"=>"0", "id"=>"15"}, "3"=>{"remove_image"=>"0", "id"=>"16"}, "4"=>{"remove_image"=>"0", "id"=>"17"}, "5"=>{"remove_image"=>"0", "id"=>"18"}}}
Run Code Online (Sandbox Code Playgroud)

但是当用这些参数更新一个对象时什么也没有发生,我错过了什么?

更新

  def update
    @country = Country.find(params[:id])

    if @country.update(country_params)
      flash[:notice] = 'Country is successfully updated.'
      redirect_to edit_admin_country_path
    else
      flash[:error] = @country.errors.full_messages[0]
      render 'edit'
    end
  end

  def country_params
    permitted = [{images_attributes: ["image", "@original_filename", "@content_type", "@headers", "_destroy", "id", "remove_image"]}]
    params.require(:country).permit(*permitted)
  end

 class Country < ActiveRecord::Base
    has_many …
Run Code Online (Sandbox Code Playgroud)

carrierwave ruby-on-rails-4

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

为什么在铁路项目中没有码显示私有方法?

我正在使用Yard生成文档,但即使在我运行时yardoc --private,它也没有显示源中私有方法的文档.

怎么了?

documentation ruby-on-rails yard

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

Retinex算法实现

我需要在C#中实现Single Scale retinex和多尺度retinex算法,
我搜索了一下但是找不到任何有用的练习项目和代码的艺术
我正确理解我应该:

  1. 将RGB转换为YUV
  2. 使用高斯模糊滤镜模糊图像
  3. 使用I'(x,y)= 255*log10(I(x,y)/ G(x,y))+ 127.5
    I - 是照明,G - 高斯核,I' - 结果图像
  4. Сonvert回YUV到RGB

此代码无法正常工作

 public static Image<Bgr, byte> SingleScaleRetinex(this Image<Bgr, byte> img, int gaussianKernelSize, double sigma)
            {
                var radius = gaussianKernelSize / 2;
                var kernelSize = 2 * radius + 1;

                var ycc = img.Convert<Ycc, byte>();

                var sum = 0f;
                var gaussKernel = new float[kernelSize * kernelSize];
                for (int i = -radius, k = 0; i <= radius; i++, k++)
                {
                    for …
Run Code Online (Sandbox Code Playgroud)

.net c# image image-processing image-enhancement

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

为 datetimepicker bootstrap 设置初始值

我无法2016-10-17T00:00:00.000+00:00使用 format 为 datetimepicker设置初始值MMMM DD, YYYY

http://jsfiddle.net/0Ltv25o8/3753/

我怎样才能做到这一点?

css twitter-bootstrap-3 bootstrap-datepicker eonasdan-datetimepicker

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

在设计中注册后不允许登录

我正在使用设计进行身份验证,在注册后设计自动登录,我只需要注册但不能登录.有类似的问题链接,但它没有帮助我

ruby-on-rails devise ruby-on-rails-3

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

工厂女孩和rspec单元测试

我正在使用factory_girl_rails和rspec并遇到麻烦,引发了以下错误

   1) WebsiteLink when link is external
         Failure/Error: website_link.external should be false

           expected #<FalseClass:0> => false
                got #<WebsiteLink:100584240> => #<WebsiteLink id: nil, website_id: nil, link: nil, external: nil, checked: nil, click_count: nil, transition_count: nil, created_at: nil, updated_at: nil, link_description: nil>

           Compared using equal?, which compares object identity,
           but expected and actual are not the same object. Use
           `expect(actual).to eq(expected)` if you don't care about
           object identity in this example.
Run Code Online (Sandbox Code Playgroud)

这是我在spec.rb文件中的代码

it "when link is external" do
    website = FactoryGirl.create(:website,site_address: "www.socpost.ru") …
Run Code Online (Sandbox Code Playgroud)

rspec ruby-on-rails factory-bot

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

如何保存设备current_user

尝试更新 current_user
\n但在递减计数器属性并收到验证错误后无法保存,最小密码长度为 6 个字符 \xe2\x80\x93

\n\n
current_user.crawl_counter -= 1\ncurrent_user.save!\n
Run Code Online (Sandbox Code Playgroud)\n\n

更新:

\n\n
class User < ActiveRecord::Base\n  devise :database_authenticatable, :registerable,\n         :recoverable, :rememberable, :trackable, :validatable\n\n  attr_accessible :email, :password, :password_confirmation, :remember_me, :crawl_counter\n  PASSWORD_REGEX = /^[a-zA-Z\\d]*$/\n  validates :password, format: { with: PASSWORD_REGEX, :message => I18n.t('errors.messages.password_invalid') }\nend\n
Run Code Online (Sandbox Code Playgroud)\n

ruby-on-rails devise

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