<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Techy Things &#187; ruby</title>
	<atom:link href="https://tech.yipp.ca/category/ruby/feed/" rel="self" type="application/rss+xml" />
	<link>https://tech.yipp.ca</link>
	<description>Just another Yipp.ca Blogs site</description>
	<lastBuildDate>Thu, 01 May 2025 18:06:28 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>https://wordpress.org/?v=4.2.38</generator>
	<item>
		<title>Unit tests in Ruby on Rails</title>
		<link>https://tech.yipp.ca/ruby-on-rails/unit-tests-ruby-rails/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=unit-tests-ruby-rails</link>
		<comments>https://tech.yipp.ca/ruby-on-rails/unit-tests-ruby-rails/#comments</comments>
		<pubDate>Sat, 04 Feb 2017 16:59:11 +0000</pubDate>
		<dc:creator><![CDATA[frank]]></dc:creator>
				<category><![CDATA[ruby]]></category>
		<category><![CDATA[ruby-on-rails]]></category>

		<guid isPermaLink="false">http://tech.yipp.ca/?p=2740</guid>
		<description><![CDATA[<p>How to write and run your first unit test for your ruby on rails webapp Fist time setup $ rake db:test:load This will recreate a new test DB based ont the current schema! Tasks&#46;&#46;&#46;</p>
<p>The post <a rel="nofollow" href="https://tech.yipp.ca/ruby-on-rails/unit-tests-ruby-rails/">Unit tests in Ruby on Rails</a> appeared first on <a rel="nofollow" href="https://tech.yipp.ca">Techy Things</a>.</p>
]]></description>
				<content:encoded><![CDATA[<p>How to write and run your first unit test for your ruby on rails webapp</p>
<h2 class="line number2 index1 alt1">Fist time setup</h2>
<div class="line number3 index2 alt2"><code class="plain plain">$ rake db:test:load</code></div>
<div class="line number3 index2 alt2">This will recreate a new test DB based ont the current schema!</div>
<div class="line number3 index2 alt2"></div>
<div class="line number3 index2 alt2">
<table>
<tbody>
<tr>
<th>Tasks</th>
<th>Description</th>
</tr>
<tr>
<td><tt>rake db:test:clone</tt></td>
<td>Recreate the test database from the current environment’s database schema</td>
</tr>
<tr>
<td><tt>rake db:test:clone_structure</tt></td>
<td>Recreate the test database from the development structure</td>
</tr>
<tr>
<td><tt>rake db:test:load</tt></td>
<td>Recreate the test database from the current <tt>schema.rb</tt></td>
</tr>
<tr>
<td><tt>rake db:test:prepare</tt></td>
<td>Check for pending migrations and load the test schema</td>
</tr>
<tr>
<td><tt>rake db:test:purge</tt></td>
<td>Empty the test database.</td>
</tr>
</tbody>
</table>
</div>
<div class="info"></div>
<h2 class="info">Writing a test</h2>
<p>&nbsp;</p>
<div class="info"></div>
<h2 class="info">Running your tests</h2>
<p>$&gt; <code class="plain plain">ruby -Itest test/unit/recette_test.rb</code></p>
<table>
<tbody>
<tr>
<th>Tasks</th>
<th>Description</th>
</tr>
<tr>
<td><tt>rake test</tt></td>
<td>Runs all unit, functional and integration tests. You can also simply run <tt>rake</tt> as the <em>test</em> target is the default.</td>
</tr>
<tr>
<td><tt>rake test:benchmark</tt></td>
<td>Benchmark the performance tests</td>
</tr>
<tr>
<td><tt>rake test:functionals</tt></td>
<td>Runs all the functional tests from <tt>test/functional</tt></td>
</tr>
<tr>
<td><tt>rake test:integration</tt></td>
<td>Runs all the integration tests from <tt>test/integration</tt></td>
</tr>
<tr>
<td><tt>rake test:plugins</tt></td>
<td>Run all the plugin tests from <tt>vendor/plugins/*/**/test</tt> (or specify with <tt>PLUGIN=_name_</tt>)</td>
</tr>
<tr>
<td><tt>rake test:profile</tt></td>
<td>Profile the performance tests</td>
</tr>
<tr>
<td><tt>rake test:recent</tt></td>
<td>Tests recent changes</td>
</tr>
<tr>
<td><tt>rake test:uncommitted</tt></td>
<td>Runs all the tests which are uncommitted. Supports Subversion and Git</td>
</tr>
<tr>
<td><tt>rake test:units</tt></td>
<td>Runs all the unit tests from <tt>test/unit</tt></td>
</tr>
</tbody>
</table>
<h2>Troubleshooting</h2>
<p>If you are on an large existing project and are just starting writing your tests you may face a couple of walking on broken glass debugging.</p>
<h3>Problem: DELETE FROM non-existing tables</h3>
<p>ActiveRecord::StatementInvalid: SQLite3::SQLException: no such table: friends: DELETE FROM "friends"</p>
<p><a href="http://tech.yipp.ca/files/2017/02/ruby-on-rails-tests-delete-from-unexisting-table.png"><img class="alignnone wp-image-2742 size-large" src="http://tech.yipp.ca/files/2017/02/ruby-on-rails-tests-delete-from-unexisting-table-800x186.png" alt="ruby-on-rails-tests-delete-from-unexisting-table" width="720" height="167" /></a></p>
<p>Let's check the log test.log</p>
<p>...<br />
[1m[36mFixture Delete (0.0ms)[0m [1mDELETE FROM "friendrequests"[0m<br />
[1m[35mFixture Delete (0.0ms)[0m DELETE FROM "friends"<br />
SQLite3::SQLException: no such table: friends: DELETE FROM "friends"<br />
...</p>
<p><span style="color: #ff6600;"><strong>The solution is surprisingly to remove a file from the test/fixture folder</strong></span></p>
<p><a href="http://tech.yipp.ca/files/2017/02/ruby-on-rails-tests-delete-from-unexisting-table-solved.png"><img class="alignnone size-full wp-image-2743" src="http://tech.yipp.ca/files/2017/02/ruby-on-rails-tests-delete-from-unexisting-table-solved.png" alt="ruby-on-rails-tests-delete-from-unexisting-table-solved" width="654" height="501" /></a></p>
<p>&nbsp;</p>
<h3>Problem: INSERT INTO a table that has no column named 'XYZ'</h3>
<p><a href="http://tech.yipp.ca/files/2017/02/ruby-on-rails-tests-insert-table-has-no-column-named.png"><img class="alignnone size-large wp-image-2747" src="http://tech.yipp.ca/files/2017/02/ruby-on-rails-tests-insert-table-has-no-column-named-800x191.png" alt="ruby-on-rails-tests-insert-table-has-no-column-named" width="720" height="172" /></a></p>
<p>&nbsp;</p>
<p><span style="color: #ff6600;"><strong>This is due to your fixture deriving from your models schema. The solution is to fix your fixtures files.</strong></span></p>
<p>In my case the solution was to change this for that :</p>
<p><a href="http://tech.yipp.ca/files/2017/02/ruby-on-rails-test-offers-yml.png"><img class="alignnone wp-image-2749 size-full" src="http://tech.yipp.ca/files/2017/02/ruby-on-rails-test-offers-yml.png" alt="ruby-on-rails-test-offers-yml" width="867" height="290" /></a></p>
<p>&nbsp;</p>
<div class="line number3 index2 alt2">
<div class="info">
<h2>Version used for this article</h2>
<p>Rails 4<br />
Ruby 2.1.9p490 (2016-03-30 revision 54437)</p>
</div>
<h2>Further suggested reading</h2>
<p>https://everydayrails.com/2012/03/12/testing-series-intro.html</p>
</div>
<p>The post <a rel="nofollow" href="https://tech.yipp.ca/ruby-on-rails/unit-tests-ruby-rails/">Unit tests in Ruby on Rails</a> appeared first on <a rel="nofollow" href="https://tech.yipp.ca">Techy Things</a>.</p>
]]></content:encoded>
			<wfw:commentRss>https://tech.yipp.ca/ruby-on-rails/unit-tests-ruby-rails/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>param is missing or the value is empty nested require permit</title>
		<link>https://tech.yipp.ca/ruby/param-missing-value-empty-nested-require-permit/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=param-missing-value-empty-nested-require-permit</link>
		<comments>https://tech.yipp.ca/ruby/param-missing-value-empty-nested-require-permit/#comments</comments>
		<pubDate>Fri, 30 Dec 2016 19:17:44 +0000</pubDate>
		<dc:creator><![CDATA[frank]]></dc:creator>
				<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://tech.yipp.ca/?p=2700</guid>
		<description><![CDATA[<p>Error: param is missing or the value is empty: home_address_attributes Before (wrong) private def user_params Rails.logger.info("PARAMS: #{params.inspect}") params.require(:user).permit(:fullname, :login, :password, :password_confirmation, :phone_home, :phone_work, :phone_cell, :deliveryNote, :home_address_attributes).require(:home_address_attributes) end After (good) private def user_params Rails.logger.info("PARAMS: #{params.inspect}")&#46;&#46;&#46;</p>
<p>The post <a rel="nofollow" href="https://tech.yipp.ca/ruby/param-missing-value-empty-nested-require-permit/">param is missing or the value is empty nested require permit</a> appeared first on <a rel="nofollow" href="https://tech.yipp.ca">Techy Things</a>.</p>
]]></description>
				<content:encoded><![CDATA[<h2>Error: param is missing or the value is empty: home_address_attributes</h2>
<h3>Before (wrong)</h3>
<pre> private
 def user_params
   Rails.logger.info("PARAMS: #{params.inspect}")
   params.require(:user).permit(:fullname, :login, :password, :password_confirmation, :phone_home, :phone_work, :phone_cell, :deliveryNote, :home_address_attributes).require(:home_address_attributes)
 end
</pre>
<h3>After (good)</h3>
<pre>  private
  def user_params
    Rails.logger.info("PARAMS: #{params.inspect}")
    params.require(:user).permit(:fullname, :login, :password, :password_confirmation, :phone_home, :phone_work, :phone_cell, :deliveryNote, 
      { home_address_attributes: [ :line1, :line2, :country, :zipCode, :province, :city ] })
  end
</pre>
<p>The documentation is there <a href="http://api.rubyonrails.org/classes/ActionController/Parameters.html#method-i-require" target="_blank">http://api.rubyonrails.org/classes/ActionController/Parameters.html#method-i-require</a></p>
<p>The post <a rel="nofollow" href="https://tech.yipp.ca/ruby/param-missing-value-empty-nested-require-permit/">param is missing or the value is empty nested require permit</a> appeared first on <a rel="nofollow" href="https://tech.yipp.ca">Techy Things</a>.</p>
]]></content:encoded>
			<wfw:commentRss>https://tech.yipp.ca/ruby/param-missing-value-empty-nested-require-permit/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>No route matches [PATCH] after upgrading to Rails 4</title>
		<link>https://tech.yipp.ca/ruby/route-matches-patch-upgrading-rails-4/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=route-matches-patch-upgrading-rails-4</link>
		<comments>https://tech.yipp.ca/ruby/route-matches-patch-upgrading-rails-4/#comments</comments>
		<pubDate>Thu, 22 Dec 2016 01:49:06 +0000</pubDate>
		<dc:creator><![CDATA[frank]]></dc:creator>
				<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://tech.yipp.ca/?p=2678</guid>
		<description><![CDATA[<p>Solution 1: Just add :patch in the route methods Solution 2: Just use resources :myobject &#160;</p>
<p>The post <a rel="nofollow" href="https://tech.yipp.ca/ruby/route-matches-patch-upgrading-rails-4/">No route matches [PATCH] after upgrading to Rails 4</a> appeared first on <a rel="nofollow" href="https://tech.yipp.ca">Techy Things</a>.</p>
]]></description>
				<content:encoded><![CDATA[<p>Solution 1: Just add :patch in the route methods</p>
<p>Solution 2: Just use resources :myobject</p>
<p>&nbsp;</p>
<p>The post <a rel="nofollow" href="https://tech.yipp.ca/ruby/route-matches-patch-upgrading-rails-4/">No route matches [PATCH] after upgrading to Rails 4</a> appeared first on <a rel="nofollow" href="https://tech.yipp.ca">Techy Things</a>.</p>
]]></content:encoded>
			<wfw:commentRss>https://tech.yipp.ca/ruby/route-matches-patch-upgrading-rails-4/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>OpenSSL::SSL::SSLError (hostname &quot;localhost&quot; does not match the server certificate):</title>
		<link>https://tech.yipp.ca/ruby/opensslsslsslerror-hostname-localhost-match-server-certificate/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=opensslsslsslerror-hostname-localhost-match-server-certificate</link>
		<comments>https://tech.yipp.ca/ruby/opensslsslsslerror-hostname-localhost-match-server-certificate/#comments</comments>
		<pubDate>Mon, 21 Nov 2016 00:21:25 +0000</pubDate>
		<dc:creator><![CDATA[frank]]></dc:creator>
				<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://tech.yipp.ca/?p=2655</guid>
		<description><![CDATA[<p>With Ruby on Rails 4 root@bronze:~# nslookup community-buy.ca Server: 8.8.8.8 Address: 8.8.8.8#53 Non-authoritative answer: Name: community-buy.ca Address: 107.6.27.108 openssl s_client -connect 107.6.27.108:443 &#124; openssl x509 -text -noout Will give you useful information</p>
<p>The post <a rel="nofollow" href="https://tech.yipp.ca/ruby/opensslsslsslerror-hostname-localhost-match-server-certificate/">OpenSSL::SSL::SSLError (hostname "localhost" does not match the server certificate):</a> appeared first on <a rel="nofollow" href="https://tech.yipp.ca">Techy Things</a>.</p>
]]></description>
				<content:encoded><![CDATA[<p>With Ruby on Rails 4</p>
<p><code><span class="pln"><br />
root@bronze:~# nslookup community-buy.ca<br />
Server: 8.8.8.8<br />
Address: 8.8.8.8#53</p>
<p>Non-authoritative answer:<br />
Name: community-buy.ca<br />
Address: 107.6.27.108</p>
<p>openssl s_client </span><span class="pun">-</span><span class="pln">connect 107.6.27.108</span><span class="pun">:</span><span class="lit">443</span> <span class="pun">|</span><span class="pln"> openssl x509 </span><span class="pun">-</span><span class="pln">text </span><span class="pun">-</span><span class="pln">noout</span></code></p>
<p>Will give you useful information</p>
<p>The post <a rel="nofollow" href="https://tech.yipp.ca/ruby/opensslsslsslerror-hostname-localhost-match-server-certificate/">OpenSSL::SSL::SSLError (hostname "localhost" does not match the server certificate):</a> appeared first on <a rel="nofollow" href="https://tech.yipp.ca">Techy Things</a>.</p>
]]></content:encoded>
			<wfw:commentRss>https://tech.yipp.ca/ruby/opensslsslsslerror-hostname-localhost-match-server-certificate/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>UserMailer OpenSSL::SSL::SSLError hostname &quot;localhost&quot; does not match the server certificate</title>
		<link>https://tech.yipp.ca/ruby/usermailer-opensslsslsslerror-hostname-localhost-match-server-certificate/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=usermailer-opensslsslsslerror-hostname-localhost-match-server-certificate</link>
		<comments>https://tech.yipp.ca/ruby/usermailer-opensslsslsslerror-hostname-localhost-match-server-certificate/#comments</comments>
		<pubDate>Tue, 20 Sep 2016 04:51:43 +0000</pubDate>
		<dc:creator><![CDATA[frank]]></dc:creator>
				<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://tech.yipp.ca/?p=2621</guid>
		<description><![CDATA[<p>OpenSSL::SSL::SSLError (hostname "localhost" does not match the server certificate): app/controllers/users_controller.rb:94:in `create' Solution &#160;</p>
<p>The post <a rel="nofollow" href="https://tech.yipp.ca/ruby/usermailer-opensslsslsslerror-hostname-localhost-match-server-certificate/">UserMailer OpenSSL::SSL::SSLError hostname "localhost" does not match the server certificate</a> appeared first on <a rel="nofollow" href="https://tech.yipp.ca">Techy Things</a>.</p>
]]></description>
				<content:encoded><![CDATA[<p>OpenSSL::SSL::SSLError (hostname "localhost" does not match the server certificate):<br />
app/controllers/users_controller.rb:94:in `create'</p>
<h2>Solution</h2>
<p>&nbsp;</p>
<p>The post <a rel="nofollow" href="https://tech.yipp.ca/ruby/usermailer-opensslsslsslerror-hostname-localhost-match-server-certificate/">UserMailer OpenSSL::SSL::SSLError hostname "localhost" does not match the server certificate</a> appeared first on <a rel="nofollow" href="https://tech.yipp.ca">Techy Things</a>.</p>
]]></content:encoded>
			<wfw:commentRss>https://tech.yipp.ca/ruby/usermailer-opensslsslsslerror-hostname-localhost-match-server-certificate/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Solr failure</title>
		<link>https://tech.yipp.ca/ruby/solr-failure/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=solr-failure</link>
		<comments>https://tech.yipp.ca/ruby/solr-failure/#comments</comments>
		<pubDate>Tue, 20 Sep 2016 04:50:23 +0000</pubDate>
		<dc:creator><![CDATA[frank]]></dc:creator>
				<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://tech.yipp.ca/?p=2619</guid>
		<description><![CDATA[<p>1735 INFO (main) [ ] o.a.s.c.SolrXmlConfig Loading container configuration from /home/cbuy/public_html/solr/solr.xml 1830 ERROR (main) [ ] o.a.s.s.SolrDispatchFilter Could not start Solr. Check solr/home property and the logs 1861 ERROR (main) [ ] o.a.s.c.SolrCore null:org.apache.solr.common.SolrException:&#46;&#46;&#46;</p>
<p>The post <a rel="nofollow" href="https://tech.yipp.ca/ruby/solr-failure/">Solr failure</a> appeared first on <a rel="nofollow" href="https://tech.yipp.ca">Techy Things</a>.</p>
]]></description>
				<content:encoded><![CDATA[<p>1735 INFO (main) [ ] o.a.s.c.SolrXmlConfig Loading container configuration from /home/cbuy/public_html/solr/solr.xml<br />
1830 ERROR (main) [ ] o.a.s.s.SolrDispatchFilter Could not start Solr. Check solr/home property and the logs<br />
1861 ERROR (main) [ ] o.a.s.c.SolrCore null:org.apache.solr.common.SolrException: Should not have found solr/@persistent<br />
. Please upgrade your solr.xml: https://cwiki.apache.org/confluence/display/solr/Format+of+solr.xml<br />
at org.apache.solr.core.SolrXmlConfig.failIfFound(SolrXmlConfig.java:168)<br />
at org.apache.solr.core.SolrXmlConfig.checkForIllegalConfig(SolrXmlConfig.java:150)<br />
at org.apache.solr.core.SolrXmlConfig.fromConfig(SolrXmlConfig.java:62)<br />
at org.apache.solr.core.SolrXmlConfig.fromInputStream(SolrXmlConfig.java:130)<br />
at org.apache.solr.core.SolrXmlConfig.fromFile(SolrXmlConfig.java:112)<br />
at org.apache.solr.core.SolrXmlConfig.fromSolrHome(SolrXmlConfig.java:140)<br />
at org.apache.solr.servlet.SolrDispatchFilter.loadNodeConfig(SolrDispatchFilter.java:162)<br />
at org.apache.solr.servlet.SolrDispatchFilter.createCoreContainer(SolrDispatchFilter.java:130)<br />
at org.apache.solr.servlet.SolrDispatchFilter.init(SolrDispatchFilter.java:109)<br />
at org.eclipse.jetty.servlet.FilterHolder.initialize(FilterHolder.java:138)<br />
at org.eclipse.jetty.servlet.ServletHandler.initialize(ServletHandler.java:852)<br />
at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:298)<br />
at org.eclipse.jetty.webapp.WebAppContext.startWebapp(WebAppContext.java:1349)<br />
at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1342)<br />
at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:741)<br />
at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:505)<br />
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)<br />
at org.eclipse.jetty.deploy.bindings.StandardStarter.processBinding(StandardStarter.java:41)<br />
at org.eclipse.jetty.deploy.AppLifeCycle.runBindings(AppLifeCycle.java:186)<br />
at org.eclipse.jetty.deploy.DeploymentManager.requestAppGoal(DeploymentManager.java:498)<br />
at org.eclipse.jetty.deploy.DeploymentManager.addApp(DeploymentManager.java:146)<br />
at org.eclipse.jetty.deploy.providers.ScanningAppProvider.fileAdded(ScanningAppProvider.java:180)<br />
at org.eclipse.jetty.deploy.providers.WebAppProvider.fileAdded(WebAppProvider.java:461)<br />
at org.eclipse.jetty.deploy.providers.ScanningAppProvider$1.fileAdded(ScanningAppProvider.java:64)<br />
at org.eclipse.jetty.util.Scanner.reportAddition(Scanner.java:609)<br />
at org.eclipse.jetty.util.Scanner.reportDifferences(Scanner.java:528)<br />
at org.eclipse.jetty.util.Scanner.scan(Scanner.java:391)<br />
at org.eclipse.jetty.util.Scanner.doStart(Scanner.java:313)<br />
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)<br />
at org.eclipse.jetty.deploy.providers.ScanningAppProvider.doStart(ScanningAppProvider.java:150)<br />
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)<br />
at org.eclipse.jetty.deploy.DeploymentManager.startAppProvider(DeploymentManager.java:560)<br />
at org.eclipse.jetty.deploy.DeploymentManager.doStart(DeploymentManager.java:235)<br />
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)<br />
at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:132)<br />
at org.eclipse.jetty.server.Server.start(Server.java:387)<br />
at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:114)<br />
at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:61)<br />
at org.eclipse.jetty.server.Server.doStart(Server.java:354)<br />
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)<br />
at org.eclipse.jetty.xml.XmlConfiguration$1.run(XmlConfiguration.java:1255)<br />
at java.security.AccessController.doPrivileged(Native Method)<br />
at org.eclipse.jetty.xml.XmlConfiguration.main(XmlConfiguration.java:1174)<br />
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)<br />
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)<br />
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)<br />
at java.lang.reflect.Method.invoke(Method.java:606)<br />
at org.eclipse.jetty.start.Main.invokeMain(Main.java:321)<br />
at org.eclipse.jetty.start.Main.start(Main.java:817)<br />
at org.eclipse.jetty.start.Main.main(Main.java:112)</p>
<p>&nbsp;</p>
<h2>Solution</h2>
<p>Downgrade from</p>
<p>gem 'sunspot_rails', '= 2.2.6'</p>
<p>to</p>
<p>gem 'sunspot_rails', '= 2.2.0'</p>
<p>or upgrade your solr.xml configuration</p>
<p>&nbsp;</p>
<p>The post <a rel="nofollow" href="https://tech.yipp.ca/ruby/solr-failure/">Solr failure</a> appeared first on <a rel="nofollow" href="https://tech.yipp.ca">Techy Things</a>.</p>
]]></content:encoded>
			<wfw:commentRss>https://tech.yipp.ca/ruby/solr-failure/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Authlogic You did not provide any details for authentication</title>
		<link>https://tech.yipp.ca/ruby/authlogic-provide-details-authentication/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=authlogic-provide-details-authentication</link>
		<comments>https://tech.yipp.ca/ruby/authlogic-provide-details-authentication/#comments</comments>
		<pubDate>Tue, 20 Sep 2016 03:36:03 +0000</pubDate>
		<dc:creator><![CDATA[frank]]></dc:creator>
				<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://tech.yipp.ca/?p=2616</guid>
		<description><![CDATA[<p>* authlogic (3.5.0) &#160; Solution Downgrade from 3.5.0 to 3.4.5 ! Modify Gemfile with gem 'authlogic', '~&#62; 3.4.5' And run again: $&#62; bundle install (...) Using scrypt 2.1.1 (was 3.0.3) Using authlogic 3.4.6 (was&#46;&#46;&#46;</p>
<p>The post <a rel="nofollow" href="https://tech.yipp.ca/ruby/authlogic-provide-details-authentication/">Authlogic You did not provide any details for authentication</a> appeared first on <a rel="nofollow" href="https://tech.yipp.ca">Techy Things</a>.</p>
]]></description>
				<content:encoded><![CDATA[<p>* authlogic (3.5.0)</p>
<p><a href="http://tech.yipp.ca/files/2016/09/authlogic-did-not-provide-details-for-authentication.png"><img class="alignnone size-full wp-image-2617" src="http://tech.yipp.ca/files/2016/09/authlogic-did-not-provide-details-for-authentication.png" alt="authlogic-did-not-provide-details-for-authentication" width="583" height="334" /></a></p>
<p>&nbsp;</p>
<h2>Solution</h2>
<p>Downgrade from 3.5.0 to 3.4.5 !</p>
<p>Modify Gemfile with</p>
<p>gem 'authlogic', '~&gt; 3.4.5'</p>
<p>And run again:</p>
<p>$&gt; bundle install</p>
<p>(...)<br />
Using scrypt 2.1.1 (was 3.0.3)<br />
Using authlogic 3.4.6 (was 3.5.0)<br />
Bundle complete! 21 Gemfile dependencies, 80 gems now installed.</p>
<p>The post <a rel="nofollow" href="https://tech.yipp.ca/ruby/authlogic-provide-details-authentication/">Authlogic You did not provide any details for authentication</a> appeared first on <a rel="nofollow" href="https://tech.yipp.ca">Techy Things</a>.</p>
]]></content:encoded>
			<wfw:commentRss>https://tech.yipp.ca/ruby/authlogic-provide-details-authentication/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Putting Ruby on Rails in Production on Debian with Virtualmin</title>
		<link>https://tech.yipp.ca/ruby/putting-ruby-rails-production-debian-virtualmin/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=putting-ruby-rails-production-debian-virtualmin</link>
		<comments>https://tech.yipp.ca/ruby/putting-ruby-rails-production-debian-virtualmin/#comments</comments>
		<pubDate>Wed, 07 Sep 2016 23:27:37 +0000</pubDate>
		<dc:creator><![CDATA[frank]]></dc:creator>
				<category><![CDATA[ruby]]></category>
		<category><![CDATA[virtualmin]]></category>

		<guid isPermaLink="false">http://tech.yipp.ca/?p=2586</guid>
		<description><![CDATA[<p>If you have 512 MB of SWAP or below you need to increase the SWAP $&#62; sudo dd if=/dev/zero of=/swap bs=1M count=1024 $&#62; sudo mkswap /swap $&#62; sudo swapon /swap To make permanent, add&#46;&#46;&#46;</p>
<p>The post <a rel="nofollow" href="https://tech.yipp.ca/ruby/putting-ruby-rails-production-debian-virtualmin/">Putting Ruby on Rails in Production on Debian with Virtualmin</a> appeared first on <a rel="nofollow" href="https://tech.yipp.ca">Techy Things</a>.</p>
]]></description>
				<content:encoded><![CDATA[<h3>If you have 512 MB of SWAP or below you need to increase the SWAP</h3>
<p>$&gt; sudo dd if=/dev/zero of=/swap bs=1M count=1024<br />
$&gt; sudo mkswap /swap<br />
$&gt; sudo swapon /swap</p>
<p>To make permanent, add this line to /etc/fstab</p>
<p>/swap swap swap sw 0 0</p>
<h3>Install Passenger</h3>
<p>$&gt; gem install passenger<br />
$&gt; apt-get install apache2-threaded-dev libapr1-dev libaprutil1-dev<br />
$&gt; passenger-install-apache2-module</p>
<p>At the end it will display for you what to add to <strong>apache global conf</strong> file, in my case :</p>
<pre>LoadModule passenger_module /usr/local/lib/ruby/gems/2.1.0/gems/passenger-5.0.30/buildout/apache2/mod_passenger.so
 &lt;IfModule mod_passenger.c&gt;
 PassengerRoot /usr/local/lib/ruby/gems/2.1.0/gems/passenger-5.0.30
 PassengerDefaultRuby /usr/local/bin/ruby
 &lt;/IfModule&gt;</pre>
<p>Also put something similar to this in the <strong>virtual host</strong> Apache config :</p>
<pre>DocumentRoot /home/cbuy/public_html/public
RailsEnv production
ErrorLog /var/log/virtualmin/community-buy.ca_error_log
CustomLog /var/log/virtualmin/community-buy.ca_access_log combined
ScriptAlias /cgi-bin/ /home/cbuy/cgi-bin/
ScriptAlias /awstats/ /home/cbuy/cgi-bin/
DirectoryIndex index.html index.htm index.php index.php4 index.php5
&lt;Directory /home/cbuy/public_html/public&gt;
allow from all
AllowOverride All
Options FollowSymLinks -MultiViews Indexes
&lt;/Directory&gt;</pre>
<p>Restart Apache</p>
<h2>Troubleshooting</h2>
<h3>Generic error</h3>
<p>Check where you can access the log file with</p>
<p>$&gt; passenger-config --detect-apache2</p>
<h3>"We're sorry, but something went wrong."</h3>
<p>Edit Apache VirtualHost configuration to run development mode to see the error:</p>
<p>RailsEnv development</p>
<p>Then restart Apache.</p>
<h3>"This web application process is being run as user 'nobody' and group 'nogroup' and must be able to access its application root directory"</h3>
<p>chown your app dir so that your user can access it. If you use virtualmin that is your domain account user.</p>
<h3>[2016-09-07 23:24:59] ERROR RuntimeError: Missing `secret_token` and `secret_key_base` for 'production' environment, set these values in `config/secrets.yml`</h3>
<p>/usr/local/lib/ruby/gems/2.1.0/gems/railties-4.2.3/lib/rails/application.rb:534:in `validate_secret_key_config!'<br />
/usr/local/lib/ruby/gems/2.1.0/gems/railties-4.2.3/lib/rails/application.rb:246:in `env_config'<br />
/usr/local/lib/ruby/gems/2.1.0/gems/railties-4.2.3/lib/rails/engine.rb:514:in `call'<br />
/usr/local/lib/ruby/gems/2.1.0/gems/railties-4.2.3/lib/rails/application.rb:165:in `call'<br />
/usr/local/lib/ruby/gems/2.1.0/gems/rack-1.6.4/lib/rack/lock.rb:17:in `call'<br />
/usr/local/lib/ruby/gems/2.1.0/gems/rack-1.6.4/lib/rack/content_length.rb:15:in `call'<br />
/usr/local/lib/ruby/gems/2.1.0/gems/rack-1.6.4/lib/rack/handler/webrick.rb:88:in `service'<br />
/usr/local/lib/ruby/2.1.0/webrick/httpserver.rb:138:in `service'<br />
/usr/local/lib/ruby/2.1.0/webrick/httpserver.rb:94:in `run'<br />
/usr/local/lib/ruby/2.1.0/webrick/server.rb:295:in `block in start_thread'</p>
<p>&nbsp;</p>
<p>Problem: Only accessible on localhost</p>
<p>Solution: RAILS_ENV=production rails server -b 0.0.0.0</p>
<p>Problem</p>
<h1>Forbidden</h1>
<p>You don't have permission to access / on this server.</p>
<p>Solution</p>
<p>You might have uploaded files as root or such that is not accessible by the Apache/passenger.</p>
<p>chown -R &lt;user&gt;:&lt;user&gt; /home/&lt;user&gt;/public_html</p>
<p>Problem : It doesnt work</p>
<p>Solution</p>
<pre class="default prettyprint prettyprinted"><code><span class="pln">RAILS_ENV</span><span class="pun">=</span><span class="pln">production bundle </span><span class="kwd">exec</span><span class="pln"> rake assets</span><span class="pun">:</span><span class="pln">precompile
</span></code></pre>
<pre class="default prettyprint prettyprinted"><code><span class="pln">config</span><span class="pun">.</span><span class="pln">serve_static_assets </span><span class="pun">=</span> <span class="kwd">true
</span></code></pre>
<pre class="default prettyprint prettyprinted"><code><span class="pln"> </span></code></pre>
<p>The post <a rel="nofollow" href="https://tech.yipp.ca/ruby/putting-ruby-rails-production-debian-virtualmin/">Putting Ruby on Rails in Production on Debian with Virtualmin</a> appeared first on <a rel="nofollow" href="https://tech.yipp.ca">Techy Things</a>.</p>
]]></content:encoded>
			<wfw:commentRss>https://tech.yipp.ca/ruby/putting-ruby-rails-production-debian-virtualmin/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Install Ruby 2.1 with Virtualmin on Debian 7</title>
		<link>https://tech.yipp.ca/ruby/install-ruby-2-1-virtualmin-debian-7/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=install-ruby-2-1-virtualmin-debian-7</link>
		<comments>https://tech.yipp.ca/ruby/install-ruby-2-1-virtualmin-debian-7/#comments</comments>
		<pubDate>Wed, 07 Sep 2016 23:26:51 +0000</pubDate>
		<dc:creator><![CDATA[frank]]></dc:creator>
				<category><![CDATA[ruby]]></category>
		<category><![CDATA[debian]]></category>
		<category><![CDATA[virtualmin]]></category>

		<guid isPermaLink="false">http://tech.yipp.ca/?p=2581</guid>
		<description><![CDATA[<p>Install Ruby 2.1 # as root apt-get update apt-get install build-essential bison openssl libreadline6 libreadline6-dev \ libyaml-dev libxml2-dev libxslt-dev zlib1g zlib1g-dev libssl-dev autoconf \ libc6-dev ncurses-dev libaprutil1-dev libffi-dev libcurl4-openssl-dev libapr1-dev cd ~ wget http://cache.ruby-lang.org/pub/ruby/2.1/ruby-2.1.9.tar.gz&#46;&#46;&#46;</p>
<p>The post <a rel="nofollow" href="https://tech.yipp.ca/ruby/install-ruby-2-1-virtualmin-debian-7/">Install Ruby 2.1 with Virtualmin on Debian 7</a> appeared first on <a rel="nofollow" href="https://tech.yipp.ca">Techy Things</a>.</p>
]]></description>
				<content:encoded><![CDATA[<h2>Install Ruby 2.1</h2>
<div class="line number1 index0 alt2"><code class="bash comments"># as root</code></div>
<div class="line number1 index0 alt2">
<div class="line number2 index1 alt1"><code class="bash plain">apt-get update</code></div>
<div class="line number6 index5 alt1"><code class="bash plain">apt-get </code><code class="bash functions">install</code> <code class="bash plain">build-essential bison openssl libreadline6 libreadline6-dev \</code></div>
<div class="line number7 index6 alt2"><code class="bash plain">libyaml-dev libxml2-dev libxslt-dev zlib1g zlib1g-dev libssl-dev autoconf \</code></div>
<div class="line number8 index7 alt1"><code class="bash plain">libc6-dev ncurses-dev libaprutil1-dev libffi-dev libcurl4-openssl-dev libapr1-dev</code></div>
<div class="line number8 index7 alt1"></div>
</div>
<div class="line number2 index1 alt1"><code class="bash functions">cd</code> <code class="bash plain">~</code></div>
<div class="line number3 index2 alt2"><code class="bash plain">wget http:</code><code class="bash plain">//cache</code><code class="bash plain">.ruby-lang.org</code><code class="bash plain">/pub/ruby/2</code><code class="bash plain">.1</code><code class="bash plain">/ruby-2</code><code class="bash plain">.1.9.</code><code class="bash functions">tar</code><code class="bash plain">.gz</code></div>
<div class="line number3 index2 alt2"></div>
<div class="line number3 index2 alt2">
<div class="line number1 index0 alt2"><code class="bash functions">tar</code><code class="bash plain">-xvf ruby-2.1.9.</code><code class="bash functions">tar</code><code class="bash plain">.gz</code></div>
<div class="line number2 index1 alt1"><code class="bash comments"># go to where it was unpacked</code></div>
<div class="line number3 index2 alt2"><code class="bash functions">cd</code><code class="bash plain">ruby-2.1.9/</code></div>
</div>
<div class="line number3 index2 alt2"></div>
<div class="line number3 index2 alt2"><code class="bash plain">.</code><code class="bash plain">/configure</code></div>
<div class="line number3 index2 alt2">
<div class="line number2 index1 alt1"><code class="bash functions">make</code></div>
<div class="line number3 index2 alt2"><code class="bash functions">make</code><code class="bash functions">test</code></div>
<div class="line number4 index3 alt1"><code class="bash functions">make</code><code class="bash functions">install</code></div>
<div class="line number4 index3 alt1"></div>
<div class="line number4 index3 alt1">
<div class="line number1 index0 alt2"><code class="bash functions">cd</code><code class="bash plain">~</code></div>
<div class="line number2 index1 alt1"><code class="bash functions">rm</code><code class="bash plain">-rf ruby-2.1.9*</code></div>
<div class="line number2 index1 alt1"></div>
</div>
<div class="line number2 index1 alt1">
<div class="line number1 index0 alt2"><code class="bash plain">ruby -</code><code class="bash functions">v</code></div>
<div class="line number2 index1 alt1"><code class="bash comments"># output: ruby 2.1.9p490 (2016-03-30 revision 54437) [x86_64-linux]<br />
</code></div>
<div class="line number2 index1 alt1"></div>
</div>
<div class="line number2 index1 alt1">Et Voilà!</div>
</div>
<div class="line number2 index1 alt1"></div>
<h3 class="line number2 index1 alt1">Troubleshooting</h3>
<div class="line number2 index1 alt1">Generating RDoc documentation<br />
Parsing sources...<br />
Killed754/961] lib/rubygems/platform.rb</div>
<div class="line number2 index1 alt1"></div>
<div class="line number2 index1 alt1"><strong>Workaround</strong></div>
<div class="line number2 index1 alt1"></div>
<div class="line number2 index1 alt1"> ./configure --disable-install-doc</div>
<div class="line number2 index1 alt1"></div>
<h2 class="line number2 index1 alt1">Configure website in Virtualmin</h2>
<div class="line number2 index1 alt1"></div>
<div class="line number2 index1 alt1">Requirement: Virtualmin versions 3.48 and above</div>
<div class="line number2 index1 alt1"></div>
<p>The post <a rel="nofollow" href="https://tech.yipp.ca/ruby/install-ruby-2-1-virtualmin-debian-7/">Install Ruby 2.1 with Virtualmin on Debian 7</a> appeared first on <a rel="nofollow" href="https://tech.yipp.ca">Techy Things</a>.</p>
]]></content:encoded>
			<wfw:commentRss>https://tech.yipp.ca/ruby/install-ruby-2-1-virtualmin-debian-7/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Upgrade Ruby 1.8 to 2.1 with ActiveRecord 4</title>
		<link>https://tech.yipp.ca/ruby/upgrade-ruby-1-8-2-1-with-activerecord-4/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=upgrade-ruby-1-8-2-1-with-activerecord-4</link>
		<comments>https://tech.yipp.ca/ruby/upgrade-ruby-1-8-2-1-with-activerecord-4/#comments</comments>
		<pubDate>Wed, 20 Jul 2016 02:07:37 +0000</pubDate>
		<dc:creator><![CDATA[frank]]></dc:creator>
				<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://tech.yipp.ca/?p=2501</guid>
		<description><![CDATA[<p>Old Forms were like this, but now they don't render! &#60;% form_for @seller, :url =&#62; "/seller/create" do &#124;f&#124; %&#62; New &#60;%= form_for @seller, :url =&#62; "/seller/create" do &#124;f&#124; %&#62; Old Partial render are also&#46;&#46;&#46;</p>
<p>The post <a rel="nofollow" href="https://tech.yipp.ca/ruby/upgrade-ruby-1-8-2-1-with-activerecord-4/">Upgrade Ruby 1.8 to 2.1 with ActiveRecord 4</a> appeared first on <a rel="nofollow" href="https://tech.yipp.ca">Techy Things</a>.</p>
]]></description>
				<content:encoded><![CDATA[<h3>Old</h3>
<p>Forms were like this, but now <strong>they don't render</strong>!</p>
<p>&lt;% form_for @seller, :url =&gt; "/seller/create" do |f| %&gt;</p>
<h3>New</h3>
<p>&lt;%= form_for @seller, :url =&gt; "/seller/create" do |f| %&gt;</p>
<h3>Old</h3>
<p>Partial render are also <strong>not rendering</strong>!</p>
<p>&lt;% seller.fields_for :address do |address_fields| %&gt;</p>
<h3>New</h3>
<p>&lt;%= seller.fields_for :address do |address_fields| %&gt;</p>
<p>Thanks to <a href="http://stackoverflow.com/questions/41275325/ruby-on-rails-4-render-partial-does-not-render" target="_blank"><strong>jamesw</strong> on stackoverflow</a> for this one !</p>
<h3>Old</h3>
<p>@friendRequests = Friendrequest.all(:conditions =&gt; { :friend_id =&gt; @user.id, :status =&gt; 0 }, :include =&gt; :requester )</p>
<p>or</p>
<p>@itemsInCart = Request.all(:conditions =&gt; ["offers.active = 1 AND requests.status = 1 AND requests.user_id = ?", @user.id], :joins =&gt; "LEFT JOIN offers on offers.id = requests.offer_id")</p>
<pre><code><a class="trace-frames" href="http://localhost:3000/products#" data-frame-id="0">activerecord (4.2.3) lib/active_record/scoping/named.rb:24:in `all'</a>
<a class="trace-frames" href="http://localhost:3000/products#" data-frame-id="1">app/controllers/products_controller.rb:40:in `index'</a></code>
</pre>
<h3>New</h3>
<pre>@friendRequests = Friendrequest.includes(:requester).where(["friend_id = :userid and status = :status", { userid: @user.id, status: 0}])

and

@itemsInCart = Request.where(["offers.active = 1 AND requests.status = 1 AND requests.user_id = :user_id", {user_id:@user.id}]).joins("LEFT JOIN offers on offers.id = requests.offer_id")


</pre>
<h3>Old</h3>
<pre>def store_location
 session[:return_to] = request.request_uri
end</pre>
<h3>New</h3>
<pre>def store_location
 session[:return_to] = request.url
end
</pre>
<h3>Old</h3>
<p>ActiveSupport::SecureRandom.hex(24)</p>
<h3>New</h3>
<p>SecureRandom.hex(24)</p>
<p>&nbsp;</p>
<h3>Old</h3>
<pre>existingRequest = Signuprequest.first(:conditions =&gt; { :unique_id =&gt; srequest.unique_id });</pre>
<p>This might error with</p>
<pre>TypeError (can't convert Hash into Integer)</pre>
<h3>New</h3>
<pre>intHex = Integer(srequest.unique_id, 16)
existingRequest = Signuprequest.where(:unique_id =&gt; intHex.to_s).first;</pre>
<h3>Old</h3>
<pre>@purchase = Purchase.first(:conditions =&gt; { :user_id =&gt; @user.id }, :order =&gt; "created_at DESC");</pre>
<h3>New</h3>
<pre>@purchase = Purchase.where(:user_id =&gt; @user.id).order("created_at DESC");</pre>
<h3>Old</h3>
<pre>UserMailer.deliver_welcome_email(@user, srequest.unique_id, websitename, request.host)</pre>
<h3>New</h3>
<pre>UserMailer.welcome_email(@user, srequest.unique_id, websitename, request.host).deliver</pre>
<p>See more at <a href="http://tech.yipp.ca/ruby/undefined-method-deliver_welcome_email-usermailerclass/">UserMailer:Class undefined method error post</a></p>
<h3>Old</h3>
<p><code>undefined method `error_messages' for #&lt;ActionView::Helpers::FormBuilder:0x0000000dccb098&gt;</code></p>
<p>&lt;% form_for @seller, :url =&gt; "/seller/create" do |f| %&gt;<br />
&lt;%= f.error_messages %&gt;</p>
<h3>New</h3>
<p>&lt;% form_for @seller, :url =&gt; "/seller/create" do |f| %&gt;<br />
&lt;% @seller.errors.full_messages.each do |msg| %&gt;<br />
&lt;p&gt;&lt;%= msg %&gt;&lt;/p&gt;<br />
&lt;% end %&gt;</p>
<h3>Old</h3>
<p><code>undefined method `url_for_file_column' for #&lt;#&lt;Class:0x00000012c13fb0&gt;:0x00000012c12700&gt;<br />
</code><br />
Solution is found in <a href="http://tech.yipp.ca/linux/replace-file_columns-ruby-rails/">how to migrate from FileColumn to CarrierWave</a></p>
<h2>Troubleshooting</h2>
<p>ActiveModel::ForbiddenAttributesError</p>
<p>@seller = Seller.new(params[:seller])</p>
<p>The post <a rel="nofollow" href="https://tech.yipp.ca/ruby/upgrade-ruby-1-8-2-1-with-activerecord-4/">Upgrade Ruby 1.8 to 2.1 with ActiveRecord 4</a> appeared first on <a rel="nofollow" href="https://tech.yipp.ca">Techy Things</a>.</p>
]]></content:encoded>
			<wfw:commentRss>https://tech.yipp.ca/ruby/upgrade-ruby-1-8-2-1-with-activerecord-4/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
