我正在尝试重定向已注册表单失败的用户(例如,他们输入了已经使用的用户名,他们将字段留空了等等...)
我为登录表单失败的用户设置了自定义故障,代码如下:
class CustomFailure < Devise::FailureApp
def redirect_url
root_path
end
def respond
if http_auth?
http_auth
else
redirect
end
end
Run Code Online (Sandbox Code Playgroud)
但是,我一直坚持如何设置注册失败.理想情况下,我只想将它们重定向回/ root_path,任何想法?谢谢!
我正在尝试允许已经将他们的Facebook帐户连接到我的rails应用程序的用户找到已经在应用程序中注册的Facebook好友,最好是以索引格式(类似于Formspring的显示).
目前我正在使用Devise,OAuth + Fbook Javascript SDK和Koala.我有每个用户的Facebook UID连接他们在数据库中保存的Facebook,但我不知道如何过滤Facebook API调用的结果@friends = @ graph.get_connections("我","朋友")为了显示与API调用数据具有匹配UID的用户.
有什么想法吗?可能还有更好的方法,所以如果需要任何其他信息,请知道.非常感谢您的帮助!
EDIT(用户控制器中索引操作的屏幕截图)

@oauth中的注释,app id和app secret在示例图像中被裁剪掉
我正在使用Devise来设置用户身份验证,但我很难让用户登录.
表单正确呈现以进行登录和注册.问题是当我点击提交时,我得到一个(没有路由匹配"/ sessions/user")错误.如果我转到注册表单,填写字段,然后提交,然后我得到同样的错误.但是,当我返回到根URL(页面#home)时,用户已登录.如果我注销,并尝试使用相同的用户凭据登录,则会收到无路由匹配错误且用户未签名在所有.
我想解决此问题,以便注册/登录重定向到页面#home并且用户从登录表单登录.有任何想法吗?
如果需要任何其他信息,请告诉我,非常感谢您的帮助!
我正在尝试使用弹出窗口创建自定义推文按钮,这部分可行.但是,我无法在文本区域中发布主题标签.
推文内容
url=http://www.mywebsite.com&text=mytweetcontent&via=mytwitterusername
Run Code Online (Sandbox Code Playgroud)
在&text =我尝试过使用mytweetcontent + #myhashtag以及尝试使用URL编码%23(与#对应); 但是,我仍然无法显示标签.关于我能做什么的任何想法?我更喜欢自定义图像,这就是为什么我没有使用专有的twitter jscript按钮.非常感谢您的帮助!
完整代码供参考:
<a href="javascript:(function(){window.twttr=window.twttr||{};var D=550,A=450,C=screen.height,B=screen.width,H=Math.round((B/2)-(D/2)),G=0,F=document,E;if(C>A){G=Math.round((C/2)-(A/2))}window.twttr.shareWin=window.open('http://twitter.com/share?url=http://www.mywebsite.com&text=%23+mytweetcontent&via=mytwitterusername','','left='+H+',top='+G+',width='+D+',height='+A+',personalbar=0,toolbar=0,scrollbars=1,resizable=1');E=F.createElement('script');E.src='http://platform.twitter.com/widgets.js';F.getElementsByTagName('head')[0].appendChild(E)}());"><img src="twitter-logo.png" border="0"></a>
Run Code Online (Sandbox Code Playgroud)
编辑*回复评论
谢谢你的建议!我没有尝试使用hashtag,只是正常,但更改&到?删除内容区域,代码如下.顶行是推文框中的结果,下面是相应的网址.
mycontent http://t.co/nKb4nWC来自@myusername
http://twitter.com/intent/tweet?text=mycontent&url=http%3A%2F%2Fwww.mywebsite.com&via=myusername
Run Code Online (Sandbox Code Playgroud)
http://t.co/YzrDfzX来自@myusername
http://twitter.com/intent/tweet?url=http%3A%2F%2Fwww.mywebsite.com%3Ftext%3Dmycontent&via=myusername
Run Code Online (Sandbox Code Playgroud) 插件: Thumbs Up和JQuery 1.5.2(另一个旧宝石需要)
当用户在帖子上投票时,我正在尝试使用完整的HTTP请求呈现更新的投票计数.目前,它会在每次投票时刷新页面.
帖子控制器
def vote_up
post = Post.find(params[:id])
current_user.vote_exclusively_for(post)
respond_to do |format|
format.js
format.html {rRedirect_to :back}
end
end
def vote_down
post = Post.find(params[:id])
current_user.vote_exclusively_against(post)
respond_to do |format|
format.js
format.html {redirect_to :back}
end
end
Run Code Online (Sandbox Code Playgroud)
投票视图(每个帖子div在左边有一个投票div(digg/reddit样式)和右边的内容)
<div class="post">
<div class="vote">
<div class="votewrapper">
<span class="votecount">
<%= post.votes_for - post.votes_against %>
</span>
<div class="votebtn">
<%= link_to image_tag('vote.png'), vote_up_post_path(post), :method => :post, :format => :js %>
</div>
</div>
</div>
<div class="postcontent">
all the post content, timestamp stuff, etc...
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
vote_up.erb.js(在帖子文件夹中). …
我正在扫描产品名称以检查其中是否存在特定字符串.现在它适用于单个字符串,但我怎样才能扫描多个字符串?例如,我想扫描苹果和微软
product.name.downcase.scan(/apple/)
Run Code Online (Sandbox Code Playgroud)
如果检测到字符串,我得到["apple"]如果没有,那么它返回nil []
我希望用户能够上传图像以用作他们的个人资料(用户#show).查看具有该功能的一些站点的源(例如Twitter),似乎为用户分配了html body标签,并且该body标签的相应CSS background-image链接到他们已上载的图像.
有关如何做到这一点的任何想法?(注意:我目前正在使用paperclip进行图片上传,但会将其与Amazon S3 /类似服务集成)
我想过从我的用户控制器向一个CSS文件/脚本注入一个ruby实例变量,以便它是动态的,但我不知道这是否可能.可能有更好的方法.