小编jam*_*mby的帖子

Twitter Bootstrap:希望警报不会移动页面的其余部分

所以说在我的用户注册(使用Devise),我在注册页面的最顶部有错误消息.

<% if @user.errors.any? %>
  <div class="alert alert-error">
    <button type="button" class="close" data-dismiss="alert">&times;</button>
    <%= devise_error_messages! %>
  </div>
<% end %>

<div><%= f.label :email %><br />
<%= f.email_field :email %></div>

<div><%= f.submit "Sign up" %></div>
Run Code Online (Sandbox Code Playgroud)

但是,当我没有放入任何内容时,尝试注册并收到错误,页面的其余部分将向下移动.我试图让错误出现在页面上方,然后得到表单,以便我可以关闭它并且没有任何内容(当我关闭时没有页面移动).

例如,在Twitter.com上,试图在没有信息的情况下登录,Twitter会询问你是否是黑人弹出框中没有移动页面的人.

我对如何获得引导来做这件事感到茫然.

我所说的是:http://i.imgur.com/UUYLkax.jpg

jquery ruby-on-rails twitter-bootstrap

4
推荐指数
2
解决办法
7514
查看次数

从部分重定向回具有部分的同一页面后保持验证错误

所以我试图从我的表单中获取错误,这些错误在我的 root_path 中呈现为部分内容。在我尝试发布它并失败(或成功)之后,我想重定向回 root_path。但是,redirect_to 决定不保存任何验证信息。

想知道如何做到这一点。

class PostsController < ApplicationController
  def new
    @post = Post.new
  end

  def create
    @nom = current_user.noms.build(params[:nom])
    if @nom.save
      flash[:success] = "Nom created!"
      redirect_to root_path
    else
      flash[:error] = @nom.errors
      redirect_to root_path
  end
Run Code Online (Sandbox Code Playgroud)

在我的主页/索引中,我呈现了帖子形式的部分内容。

= form_for [current_user, @post] do |f|
  = f.text_field :name
  = f.select :category
  = f.text_area :description
  = f.submit "Post", class: "btn btn-primary"

  - @post.errors.full_messages.each do |msg|
    %p
      = msg
Run Code Online (Sandbox Code Playgroud)

在重定向到 root_path 后,它应该将错误保留在表单的底部。

我还想保留验证失败后的信息。

ruby-on-rails

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

如何通过Icalendar gem获取RSVP按钮

所以我在我的ruby项目中得到了Icalendar宝石.我试图在邀请中获得Yes/No/Maybe的RSVP按钮,但每当它被发送时我只会得到一个"添加到日历".

想知道我还需要什么:

def make_ical_appointment(start_time, end_time, uid, email_one, email_two)
  ical = Icalendar::Calendar.new
  ical.timezone.tzid = "UTC"

  e = Icalendar::Event.new
  e.dtstart = start_time
  e.dtend = end_time
  e.organizer = %W(mailto:#{email_one} mailto#{email_two})
  e.uid = uid

  ical.add_event(e)
  ical.publish

  mail.attachments['appointment.ics'] = { mime_type: 'application/ics', content: ical.to_ical }
end
Run Code Online (Sandbox Code Playgroud)

我读过人们需要将它设置为METHOD:REQUEST,但我不确定在那里做什么.我还读到你需要设置与会者,但是如果你有警报,你似乎只能设置与会者?

只是想让它看起来像一个普通的邀请.

ruby icalendar ruby-on-rails

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