image_tag没有使用我设置的asset_host.有什么想法吗?我能想到的唯一一件事就是它与梅勒有关.
配置/环境/ development.rb
config.action_controller.asset_host = "http://localhost:3000"
Run Code Online (Sandbox Code Playgroud)
myMailer.rb
<%= image_tag "logo.png", :style=>"margin-left:10px; padding-bottom:15px;" %>
Run Code Online (Sandbox Code Playgroud)
呈现为:
<img alt="Logo" src="/images/logo.png?1303090162" style="margin-left:10px; padding-bottom:15px;" />
Run Code Online (Sandbox Code Playgroud)
在控制台中:
> MyApp::Application.config.action_controller
#<OrderedHash {… :asset_host=>"http://localhost:3000", …}>
Run Code Online (Sandbox Code Playgroud)
我需要image_tag来创建完整路径网址,因为它会显示在电子邮件中.
我已经设置了一个MFMailComposeViewController,它可以在iPhone上正常工作,但在iPad上崩溃,说:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Application tried to present a nil modal view controller on target...
Run Code Online (Sandbox Code Playgroud)
那么为什么会创建一个零模态视图呢?
MFMailComposeViewController *message = [[MFMailComposeViewController alloc] init];
[message setMessageBody:@"My message here" isHTML:NO];
[message setToRecipients:[NSArray arrayWithObject:@"my@domain.com"]];
[message setSubject:@"Request Info"];
message.mailComposeDelegate = self;
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
message.modalPresentationStyle = UIModalPresentationFormSheet;
[self presentModalViewController:message animated:YES];
[message release];
Run Code Online (Sandbox Code Playgroud)
有任何想法吗?
我正在升级我的项目以使用Cocoapods,当我尝试为iOS设备或模拟器构建项目时,我得到:
Undefined symbols for architecture armv7:
"_OBJC_CLASS_$_TestFlight", referenced from:
objc-class-ref in PhotoPreviewViewController.o
"_OBJC_CLASS_$_Flurry", referenced from:
objc-class-ref in MyAppDelegate.o
objc-class-ref in InitialSetupViewController.o
objc-class-ref in InitialDownloadViewController.o
objc-class-ref in HistoryViewController.o
ld: symbol(s) not found for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Run Code Online (Sandbox Code Playgroud)
(当然,架构不同)
在"Link Binary With Libraries"下libPods.a是黑色的,所以我认为那里没有任何问题.它也正在对它们进行自动完成,所以我不确定为什么它在编译时没有找到它们.
有什么建议?
我正在尝试将网站分成两部分.一个应该使用应用程序布局,一个应该使用管理布局.在我的application.rb中,我创建了一个函数如下:
def admin_layout
if current_user.is_able_to('siteadmin')
render :layout => 'admin'
else
render :layout => 'application'
end
end
Run Code Online (Sandbox Code Playgroud)
在控制器里,它可能是我放的一个或另一个
before_filter :admin_layout
Run Code Online (Sandbox Code Playgroud)
这适用于某些页面(其中只是文本),但对于其他页面,我得到了经典错误:
You have a nil object when you didn't expect it!
You might have expected an instance of Array.
The error occurred while evaluating nil.each
Run Code Online (Sandbox Code Playgroud)
有没有人知道我错过了什么?我该如何正确使用渲染和布局?
假设用户单击指向受保护页面的链接.然后将它们重定向到登录屏幕,然后登录.如果有,则成功重定向到该页面.但如果他们没有帐户,他们必须注册.事情变得棘手,因为我正在做电子邮件确认.
通过单击链接创建新会话,我无法自动将用户重定向到该受保护页面.我试图通过在确认链接中添加对重定向的引用来更改它.我想要做:
<%= link_to 'Confirm my account', confirmation_url(@resource, :confirmation_token => @resource.confirmation_token, :redirect_to => stored_location_for(@resource)) %>
Run Code Online (Sandbox Code Playgroud)
但我无法弄清楚如何获取stored_location_for(或者如果这是正确的位置).它是在中定义的Devise::Controllers::Helpers,但它是一个实例方法,所以我不能这样做Devise::Controllers::Helpers.stored_location_for(…).
我的问题是我如何访问stored_location_forOR更好的方法是什么?
我的目标是这样做,然后在我的自定义ConfirmationsController中定义:
def show
if params[:redirect_to]
session["user_return_to"] = params[:redirect_to]
end
super
end
Run Code Online (Sandbox Code Playgroud)
这应该工作正常吗?
我一直试图解决这个问题2天.我正在通过电子邮件确认确认用户帐户(通过Devise).我终于完成了所有工作,但重点是确认一个人拥有他们声称拥有的电子邮件.因此,每当用户更改其电子邮件时,我都需要再次确认.
为了做到这一点,我已经创建registrations_controller并编写了该update方法.主要基于Devise的基础,但我检查是否需要根据更新发送确认.
# registrations_controller.rb
def update
self.resource = resource_class.to_adapter.get!(send(:"current_#{resource_name}").to_key)
send_confirmation = false
if params[:user][:email] != resource.email
send_confirmation = true
end
if resource.update_with_password(params[resource_name])
set_flash_message :notice, :updated if is_navigational_format?
sign_in resource_name, resource, :bypass => true
if send_confirmation
resource.update_attributes(:confirmed_at => nil, :confirmation_sent_at => nil)
resource.send_confirmation_instructions
end
respond_with resource, :location => after_update_path_for(resource)
else
clean_up_passwords(resource)
respond_with_navigational(resource){ render_with_scope :edit }
end
end
Run Code Online (Sandbox Code Playgroud)
我的问题是我不知道在哪个过程中能够改变重定向的位置.我有一个页面说明"已发送电子邮件以确认您的电子邮件".但是,如果我send_confirmation_instructions在用户点击"更新帐户" 后尝试将其删除,则会将其注销(推送到登录屏幕),然后当他们通过电子邮件确认帐户时,会将其定向到我想要显示的页面他们.
我有一个定制的Warden策略,其中有一些放入其中,我还编写了Devise放入的前过滤器:
# registrations_controller.rb
def authenticate_scope!
puts "RegistrationsController :: authenticate_scope!"
puts "action : #{params[:action]}"
super
end
Run Code Online (Sandbox Code Playgroud)
所以看起来它正在尝试验证用户.日志内容如下: …
我正在设置我的UIView(在UIViewController中)的背景颜色,如下所示:
myView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"myTransparentBG.png"]];
Run Code Online (Sandbox Code Playgroud)
我甚至试过搞乱,[myView setOpaque:NO];但图像看起来并不透明.它有黑色背景.我是否愿意以编程方式修复此问题?否则,我们如何设置透明背景到我们的视图?
这似乎是一个本来应该问过的问题,但我找不到答案.
我有UIButton,我设置三种状态的背景图像,正常,突出显示和禁用,所有状态都采用以下格式:
[button setBackgroundImage:buttonBGD forState:UIControlStateDisabled];
Run Code Online (Sandbox Code Playgroud)
我的问题是,当按钮被禁用时,iPhone选择为我减轻图像.这是不希望的.但如果我告诉它:
[button setAdjustsImageWhenDisabled:NO];
Run Code Online (Sandbox Code Playgroud)
然后图像根本不会改变.如何删除图像的自动闪亮,而只使用我创建的原始图像?
我试图更好地理解 Swift 中的协议。特别是可选的协议方法。我认为这个问题可能与我在不同文件中定义/使用的协议有关,但是如果您将以下内容放在操场上,您会遇到同样的问题:
import Foundation
@objc protocol MyProtocol {
optional func shouldJump() -> Bool
}
extension NSObject : MyProtocol {}
class Test {
func testJump() {
let object = NSObject()
let jump = object.shouldJump?() ?? true
print("should jump: \(jump)")
}
}
let t = Test()
t.testJump()
Run Code Online (Sandbox Code Playgroud)
这是错误消息:
error: value of type 'NSObject' has no member 'shouldJump'
let jump = object.shouldJump?() ?? true
^~~~~~ ~~~~~~~~~~
Run Code Online (Sandbox Code Playgroud)
出于某种原因,它不接受已在 NSObject 上定义的协议。代码完成找到它,但编译器不让它通过。
我不确定我的?? true部分是否会起作用,但我希望它是默认值,以防未定义该方法。
我如何让这个工作?
iphone ×3
devise ×2
xcode ×2
actionmailer ×1
cocoapods ×1
flurry ×1
git ×1
ipad ×1
layout ×1
mfmailcomposeviewcontroller ×1
png ×1
render ×1
swift ×1
testflight ×1
transparency ×1
uibutton ×1
uiview ×1