小编Mar*_*els的帖子

Rails:如何修改嵌套资源的测试?

在学习Rails时,我创建了一个应用程序,其Domains控制器嵌套在Customers控制器下面.我正在使用Rails 2.3.4,这是一次学习经历.我设法得到以下路由设置:

    customer_domains GET    /customers/:customer_id/domains(.:format)          {:controller=>"domains", :action=>"index"}
                     POST   /customers/:customer_id/domains(.:format)          {:controller=>"domains", :action=>"create"}
 new_customer_domain GET    /customers/:customer_id/domains/new(.:format)      {:controller=>"domains", :action=>"new"}
edit_customer_domain GET    /customers/:customer_id/domains/:id/edit(.:format) {:controller=>"domains", :action=>"edit"}
     customer_domain GET    /customers/:customer_id/domains/:id(.:format)      {:controller=>"domains", :action=>"show"}
                     PUT    /customers/:customer_id/domains/:id(.:format)      {:controller=>"domains", :action=>"update"}
                     DELETE /customers/:customer_id/domains/:id(.:format)      {:controller=>"domains", :action=>"destroy"}
           customers GET    /customers(.:format)                               {:controller=>"customers", :action=>"index"}
                     POST   /customers(.:format)                               {:controller=>"customers", :action=>"create"}
        new_customer GET    /customers/new(.:format)                           {:controller=>"customers", :action=>"new"}
       edit_customer GET    /customers/:id/edit(.:format)                      {:controller=>"customers", :action=>"edit"}
            customer GET    /customers/:id(.:format)                           {:controller=>"customers", :action=>"show"}
                     PUT    /customers/:id(.:format)                           {:controller=>"customers", :action=>"update"}
                     DELETE /customers/:id(.:format)                           {:controller=>"customers", :action=>"destroy"}
                root        /                                                  {:controller=>"customers", :action=>"index"}
Run Code Online (Sandbox Code Playgroud)

但是,由于路由错误,域控制器的所有测试都会失败.

例如,以下测试(由Rails的资源生成器生成)失败,DomainsControllerTest类中的所有其他测试也失败.

class DomainsControllerTest …
Run Code Online (Sandbox Code Playgroud)

testing routing nested ruby-on-rails

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

使用GET参数时,Apache Redirect 301失败,例如?blah =

我为客户构建了一个新的PHP站点,并希望将排名最高的Google结果从旧站点结构重定向到新站点结构.

我在文档中将几十个Redirect 301放在.htaccess中,虽然有些工作正常,但我遇到了很多其他问题.

这很好用:

Redirect 301 /nl/flash/banner_new.swf http://www.example.com/actueel/nieuws.html?action=show&f_id=152
Run Code Online (Sandbox Code Playgroud)

这不起作用!(由于简单地跳过重定向,导致404):

Redirect 301 /nl/index.php?mID=24511&subID=0 http://www.example.com/solutions/printsolutions.html
Redirect 301 /nl/index.php?mID=24512&subID=0 http://www.example.com/support/koppeling-met-omgeving.html
Run Code Online (Sandbox Code Playgroud)

重定向在.htaccess文件中混合,只有带有GET参数的重定向才会失败.

有解决方法吗?忽略失败的重定向不是客户的选择.谢谢你的想法.

apache .htaccess seo redirect get

18
推荐指数
3
解决办法
3万
查看次数

在GUI方式的Magento中设置全局变量?

我最近开始使用Magento作为客户的网上商店,仍然需要掌握它的系统.

网上商店应该有几个链接,并从公司网站所在的另一个域获取信息.我宁愿不对域名或URL进行硬编码,而是在某个地方定义它,并在整个网店的phtml模板中使用该值.这使我们在开发,登台和生产URL之间移动网站时可以轻松调整它.

任何人都可以建议采用Magento的方式吗?我们最好在后端添加一个字段到Store的Config GUI,类似于{{base_url}}的设置方式.或者也许我在想错误的方法?

php xml configuration magento

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

如何从Magento外部访问Magento用户的会话?

我试图访问我网站另一部分的Magento客户会话.

domain.com/shop/ <- Magento
domain.com/test.php
Run Code Online (Sandbox Code Playgroud)

商店本身就像一个魅力,但我试图在test.php中确定一个客户是否登录,所以我可以显示他的名字与他的购物车的链接.

目前test.php的内容:

<?php
require_once dirname(__FILE__).'/shop/app/Mage.php';
umask(0);
Mage::app('default');
Mage::getSingleton('core/session', array('name' => 'frontend'));
var_dump(Mage::getSingleton('customer/session')->isLoggedIn());
?>
Run Code Online (Sandbox Code Playgroud)

我一直得到布尔(假)返回.我在domain.com/shop/登录了Magento,所以预计"真实".

我忘记了什么吗?

php oop session magento e-commerce

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

Magento:如何预填充产品的下拉属性值

我正在为客户建立一个Magento商店,并希望为所有作为下拉列表的产品添加属性.就像'制造商'属性一样.

但是,我不想手动输入属性的值列表,而是希望从外部站点填充值.因此,每次创建新产品或编辑现有产品时,下拉列表都会填充从远程站点检索到的最新值列表.在创建属性期间不应仅提取一次列表,而是每次创建或编辑产品时.

例如,假设您可以通过远程站点的curl获取所有制造商的列表.此列表中的名称偶尔会被修改或添加,但ID保持不变,因此应在幕后使用.您如何预先填写制造商下拉列表的值?

我知道如何创建一个基本的自定义扩展,但扩展adminhtml后端对我来说是新的东西.

任何帮助表示赞赏.

php magento drop-down-menu

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