小编Joh*_*ohn的帖子

添加字段以设计注册视图后,"无法重定向到nil"错误

将此行添加到devise/registrations/new.html.haml文件(视图)后:

  %div
    = f.label :account_type
    %br/
    = f.select(:account_type, [["Usertype1","usertype1"],["Usertype2","usertype2"]], {:selected => nil, :prompt => 'Pick One'})
Run Code Online (Sandbox Code Playgroud)

单击确认电子邮件中的确认链接后出现以下错误:

ActionController::ActionControllerError in Devise::ConfirmationsController#show

Cannot redirect to nil!
Run Code Online (Sandbox Code Playgroud)

只有在我注册时选择Usertype2才会发生这种情况.我还将account_type设为attr_accessible.account_type似乎已分配(我在rails控制台中检查过),开发日志没有任何进一步的信息.

我认为这是发生错误的设备确认控制器中的行:

respond_with_navigational(resource){ redirect_to after_confirmation_path_for(resource_name, resource) }
Run Code Online (Sandbox Code Playgroud)

此外,该帐户正在确认,但在尝试登录时,我得到以下内容:

undefined method `user_url' for #<Devise::SessionsController:0x9d1659c>
Run Code Online (Sandbox Code Playgroud)

这是在设计会话控制器的创建操作中.

任何帮助,将不胜感激.谢谢!

约翰

ruby-on-rails devise ruby-on-rails-3.1

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

你如何在emberjs中创建一个隐藏的文本字段?

我想用表单传递一个参数,并希望将它存储在模板中的隐藏字段中.怎么在emberjs中完成?我从这里的文档中看到你可以这样做:

{{view Ember.TextField valueBinding="firstName"}}
Run Code Online (Sandbox Code Playgroud)

但如何制作一个隐藏的?或者是一个隐藏的文本字段,不应该在前端处理?

ember.js

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

我如何使用cron作业发送HTML GET请求?

我想设置一个cron作业,它向网址发送一个http请求.我该怎么做?我以前从未设置过cronjob.

shell cron http

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

ActiveAdmin与Rails 3.1打破javascript

我刚刚使用我的Rails 3.1应用程序实现了ActiveAdmin gem,并且它导致了我的应用程序中允许ajax发布评论的一些javascript问题.删除active_admin.js文件会导致问题消失.如何在保留我的应用程序功能的同时保留active_admin的javascript?关于问题可能是什么的任何想法?

active_admin.js的内容:

//= require active_admin/base
Run Code Online (Sandbox Code Playgroud)

我的application.js文件的内容:

//= require jquery
//= require jquery_ujs
//= require_tree .
Run Code Online (Sandbox Code Playgroud)

由ActiveAdmin破坏的Javascript:

jQuery -> 
$('.addcomment').live("click", ->
 $(this).closest('.comment_area').find('.add_comment_box').parent().removeClass("add_comments_box_hidden").addClass('add_comments_box')
    return false )

init_csrf = ->
  window._settings.token = $('meta[name="csrf-token"]').attr 'content'
  $.ajaxSetup
    beforeSend: (xhr) ->
      xhr.setRequestHeader "X-CSRF-Token", _settings.token

jQuery ->
    $('.post_comment_btn').live("click", ->
        $(this).closest('.comment_area').addClass('add_comment_here')
        $.post(
            '/comments'
            $(this).closest('form').serialize()
            null
            "script"
        )
        return false )
Run Code Online (Sandbox Code Playgroud)

链接到active_admin github页面.

javascript ruby-on-rails ruby-on-rails-3.1 activeadmin

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

语法错误,意外的keyword_ensure,期望$ end,在HAML中使用form_tag

在我将以下代码中的"form {:action =>"/ comments"}"替换为"form_tag('/ comments')"之后:

  =form_tag('/comments')
    %fieldset
      %input.comment_input{ :name => "comment[comment]", :size => 60, :type => "text" }
      %input{ :name => "comment[activity_id]", :type => 'hidden', :value => "#{activity.id}" } 
      %button.post_coment_btn{ :type => "submit", :formmethod => "post"} Add Comment
Run Code Online (Sandbox Code Playgroud)

然后我得到以下错误:

syntax error, unexpected keyword_ensure, expecting $end
Run Code Online (Sandbox Code Playgroud)

..在第18行,但包含上述文件的文件只有17行.我是否错误地使用了form_tag?

< - 更新 - >

使用form_tag执行@Ben Zhang所表明的只是我实际上想要转到'comments'控制器中的'create'动作:

=form_tag :action => 'create', :controller => 'comments' do
Run Code Online (Sandbox Code Playgroud)

forms haml ruby-on-rails

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

如何在Rails中使用form_for中的select方法

我想在Rails中使用form_for中的select方法.我不太清楚该怎么做.谁能指点我一个例子?

ruby-on-rails form-for

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

在Ruby中使用引号中的通配符运算符?

我想在rails应用程序中设置一个前置过滤器,如下所示:

before_filter :set_instance_variables, :unless => :active_pages?

def active_pages?
  params[:controller] == "admin/*"
end
Run Code Online (Sandbox Code Playgroud)

我希望它有*表示任何单词,以便该方法检查任何以'admin /'开头的控制器.我认为星号可能是一张外卡并起作用,但似乎没有用.我怎么能做到这一点?

ruby ruby-on-rails

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

Rails应用程序中的RSS给出错误:标记<source>中缺少属性<url>

我想在我的Rails应用程序中显示华盛顿邮政政治RSS提要.

wp_url = 'http://feeds.washingtonpost.com/rss/politics'
open(wp_url) do |rss|
  @wp_feed = RSS::Parser.parse(rss)
end
Run Code Online (Sandbox Code Playgroud)

使用该代码,我收到错误:

attribute <url> is missing in tag <source>
Run Code Online (Sandbox Code Playgroud)

我究竟做错了什么?

ruby rss ruby-on-rails-3

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

在Ruby中,如何使用现有实例的所有相同属性值(除了id)来创建模型的新实例

我正在开发一个Ruby on Rails应用程序,我有一个名为Activity的模型.我希望能够创建一个新的Activity实例,并将它作为现有Activity实例的精确副本,除了它具有不同的ID.我怎样才能做到这一点?

ruby ruby-on-rails

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

'NoneType'对象在python中没有属性'append'

我在python中有以下函数:

def find_str(s, m):
    starting_points = find_starting_points(s,m)
    solution = []
    for i in range(0, len(starting_points)):
        position = starting_points[i]
        solution.append([position])
        solution = build_solution(position, s, m, solution)
    return solution
    pass
Run Code Online (Sandbox Code Playgroud)

当我在ipython中运行该文件时,我收到以下错误:

     55     for i in range(0, len(starting_points)):
     56         position = starting_points[i]
---> 57         solution.append([position])
     58         solution = build_solution(position, s, m, solution)
     59     return solution

AttributeError: 'NoneType' object has no attribute 'append'
Run Code Online (Sandbox Code Playgroud)

为什么我会收到这个错误?

python

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