Error when creating db with Blog engine - ruby-on-rails-3

I've installed a RefineryCMS application, and everything was working fine until I decided to install its Blog engine.
We I ran the app migrations (including Blog) from scratch, I've received the following error:
Mysql2::Error: Unknown column 'custom_title' in 'field list': INSERT INTO `pages` (`browser_title`, `path`, `meta_description`, `created_at`, `link_url`, `custom_title_type`, `draft`, `title`, `skip_to_first_child`, `deletable`, `updated_at`, `position`, `rgt`, `custom_title`, `meta_keywords`, `parent_id`, `menu_match`, `lft`, `show_in_menu`, `depth`) VALUES (NULL, NULL, NULL, '2011-03-10 16:32:08', '/blog', 'none', 0, 'Blog', 0, 0, '2011-03-10 16:32:08', 2, 8, NULL, NULL, NULL, '^/blogs?(/|/.+?|)$', 7, 1, NULL)
I've seen this is a known issue, but I cannot find a neat solution for both development and production environments.
BTW, I saw this happening with a custom engine installed by me using rails g engine_name command. The weird thing is that it doesn't happen if you run these migrations after all the previous ones have been run before. It just happens when runnning all the app migrations from scratch.
Any ideas?
UPDATE:
This is my db/seeds/refinerycms_blog.rb file looks like after the comment I've received here:
Page.reset_column_information
User.find(:all).each do |user|
user.plugins.create(:name => "refinerycms_blog",
:position => (user.plugins.maximum(:position) || -1) +1)
end
page = Page.create(
:title => "Blog",
:link_url => "/blog",
:deletable => false,
:position => ((Page.maximum(:position, :conditions => {:parent_id => nil}) || -1)+1),
:menu_match => "^/blogs?(\/|\/.+?|)$"
)
Page.default_parts.each do |default_page_part|
page.parts.create(:title => default_page_part, :body => nil)
end
But it's still not working. Any ideas?

Add the following to the top of the blog seeds files that it copied into db/seeds/:
Page.reset_column_information

Related

Unable to run migrations on GCP with CakePHP 3.8

I am trying to set up my CakePHP 3.8 project on a GCP "Compute Engine" VM.
I have set up my app.php to use the following DB configuration:
'className' => 'Cake\Database\Connection',
'driver' => 'Cake\Database\Driver\Mysql',
'persistent' => false,
'datasource' => 'Database/Mysql',
'persistent' => false,
'host' => 'localhost',
'username' => 'user',
'password' => 'password',
'database' => 'dbname',
'prefix' => '',
'encoding' => 'utf8',
'timezone' => 'UTC',
'cacheMetadata' => true,
'log' => false,
'flags' => [
PDO::MYSQL_ATTR_INIT_COMMAND => "SET ##SESSION.sql_mode='';",
// uncomment below for use with Google Cloud SQL
PDO::MYSQL_ATTR_SSL_KEY => CONFIG.'ssl/client-key.pem',
PDO::MYSQL_ATTR_SSL_CERT => CONFIG.'ssl/client-cert.pem',
PDO::MYSQL_ATTR_SSL_CA => CONFIG.'ssl/server-ca.pem',
PDO::MYSQL_ATTR_SSL_VERIFY_SERVER_CERT => false
],
'cacheMetadata' => true,
'log' => false,
My problem happens when I try to run migrations. The site works just fine with the above configuration, however, if I run
$> php bin/cake.php migrations migrate
I get a slew of errors saying that it cannot connect, access denied for user#host.
If I add
'ssl_key' => CONFIG .'ssl/client-key.pem',
'ssl_cert' => CONFIG . 'ssl/client-cert.pem',
'ssl_ca' => CONFIG . 'ssl/server-ca.pem',
I get an error:
Caused by: [PDOException] PDO::__construct(): Peer certificate CN=`gcpname:gcpserver' did not match expected CN=`111.111.111.111' in /var/www/mydomain.com/vendor/robmorgan/phinx/src/Phinx/Db/Adapter/PdoAdapter.php on line 79
I guess this is because the migrations plugin still doesn't pass the flags or custom mysql_attr_* options over to the Phinx connection configuration, see this issue:
https://github.com/cakephp/migrations/issues/374
I don't think there's much that can be done here, other than adding support for flags / attribute options, or using Phinx directly (ie without the Migrations plugin).
I've pushed a PR that would add support for driver specific flags, you might want to give it a try and comment on the issue or the PR whether it works for you (it's for CakePHP 4.x (Migrations 3.x), I'll backport it for CakePHP 3.x (Migrations 2.x) in case it's being accepted):
https://github.com/cakephp/migrations/pull/478

Codeigniter to SQL-Server connection using XAMPP

Currently my project is running on
XAMPP Version 1.7.3
Codeigniter Version 2.1.4
SQL-Server - Microsoft SQL Server 2012 (SP4-GDR) (KB4057116) - 11.0.7462.6 (X64)
It was running fine but the database is growing day by day and the performance is also getting slower in the same manner. Besides that, due to few other major concerns we are forced to migrate to SQL-Server. Now the database is completely migrated to SQL-Server from MySQL.
The problem is in the connection Codeigniter -> SQL-Server while using XAMPP server. I have tried so many codes that is found in the google but none of these working. One I have is
$active_group = 'default';
$query_builder = TRUE;
$db['default'] = array(
'dsn' => '',
'hostname' => 'MSSQLSERVER',
'username' => '',
'password' => '',
'database' => 'test', --changed
'dbdriver' => 'sqlsrv',
'dbprefix' => '',
'pconnect' => FALSE,
'db_debug' => (ENVIRONMENT !== 'production'),
'cache_on' => FALSE,
'cachedir' => '',
'char_set' => 'utf8',
'dbcollat' => 'utf8_general_ci',
'swap_pre' => '',
'encrypt' => FALSE,
'compress' => FALSE,
'stricton' => FALSE,
'failover' => array(),
'save_queries' => TRUE
);
I am a database developer so couldn't make any additions to the code due to lack of ideas. So, can you plese share your ideas to resolve this problem. I am expecting it in detail steps. It’s no problem If I need to upgrade my versions or change anything else, but I can't change the framework itself.
This process was bit easier for me but being a database developer, it gonna bit harder for you. No worries, if you follow the instructions properly then it will work in a single shot
1- Setup CI configuration files and other setup from the following link
https://futbolsalas15.wordpress.com/2014/02/23/7-steps-to-make-sql-server-and-codeigniter-works/
After doing the above changes, It will still remain incomplete in my case and I did the below additional changes
IN FILE: system\database\DB.php
require_once(BASEPATH.'database/DB_driver.php'); --Find this line
$active_record=TRUE; --Add this line below
IN FILE: system\database\DB_driver.php
var $dbdriver = 'mysql'; --Replace `mysql` with `sqlsrv`
SP calling method, suppose you have sp_report with four parameters as below:
--From Mysql
$call_proc = "CALL sp_report('b', 'a', $date_from, $date_to)"
--From SQLServer
$call_proc = "DECLARE #p_report_type CHAR(1) = 'b',
#p_sub_type CHAR(1) = 'a',
#p_date_from VARCHAR(10) = '".$date_from."',
#p_date_to VARCHAR(10) = '".$date_to."'
EXEC sp_report #p_report_type, #p_sub_type, #p_date_from, #p_date_to"
Thats all my friend, hope it will work as expected.

Bigcommerce API start

first of all, sorry for this silly question
but I am new to use big commerce API and I searched and found many threads but not works for me .
the composer created a directory vendor
then its root I have to create a file index.php and put this code but it's showing me the blank page
<?php
require 'vendor/autoload.php';
use Bigcommerce\Api\Client as Bigcommerce;
Bigcommerce::configure(array(
'store_url' => 'https://store-xxxx.mybigcommerce.com/api/v2/',
'username' => 'xxxx',
'api_key' => 'xxxx'
));
Bigcommerce::verifyPeer(false);
$ping = Bigcommerce::getTime();
if ($ping) echo $ping->format('H:i:s');
$filter = array("page" => 3, "limit" => 30);
$products = Bigcommerce::getProducts($filter);
?>
Please, someone, explain all steps with the easy understandable process ?
Sometimes it's giving
Fatal error: Class 'Bigcommerce_Api' not found in C:\xampp\htdocs\bigcommerceapi\index.php on line 30
I followed this community
https://c9.io/oschino/bigcommerce-api-php-oauth
when I clicking the single file link it's showing 404 not found where from I can download big commerce.php file
Also, I want to know if composer created a whole PHP API then is it it is necessary to download big commerce PHP API from Github ?
I have checked the folder structure and files are same in vendor folder and big commerce git hub files.
Please help
I got solution the bigcoomerce store URL call process is now changed
I changed
Bigcommerce::configure(array(
'store_url' => 'https://store-xxxx.mybigcommerce.com/api/v2/',
'username' => 'xxxx',
'api_key' => 'xxxx'
));
to like this
Bigcommerce::configure(array(
'store_url' => 'https://store-xxxx.mybigcommerce.com',
'username' => 'xxxx',
'api_key' => 'xxxx'
));

Mandrill's UNSUB merge tag not getting parsed

I'm trying to make it so when someone clicks on the unsubscribe link in an email sent via the Mandrill API (using PHP) it works as described in: http://help.mandrill.com/entries/23815367-Can-I-add-an-automatic-unsubscribe-link-to-Mandrill-emails-
The *|UNSUB|* merge tag is not getting parsed. It just comes through in the the body of the email received.
Near the end of the message content ($message_content) I have:
Click here to unsubscribe.
In Gmail, the link is: Click here to unsubscribe.
(NOT a valid HREF, so Gmail just ignores the anchor tag)
In Outlook 2010 the link is: Click here to unsubscribe.
(Not a valid HREF)
Is there some merge_vars parameter I should add to the headers?
http://help.mandrill.com/entries/21678522-How-do-I-use-merge-tags-to-add-dynamic-content- mentions them, but I can't find what the parameter should be for the UNSUB merge tag.
$mandrill = new Mandrill($mandrill_api_key);
$message = array(
'html' => $message_content,
'subject' => $subject,
'from_email' => 'me#mydomain.com',
'from_name' => 'MY NAME',
'to' => $to_list,
'headers' => array('Reply-To' => 'me#mydomain.com'),
'important' => false,
'track_opens' => 1,
'track_clicks' => null,
'auto_text' => null,
'auto_html' => null,
'inline_css' => null,
'url_strip_qs' => null,
'preserve_recipients' => 0,
'view_content_link' => 1,
'tracking_domain' => null,
'signing_domain' => null,
'return_path_domain' => null,
'merge' => true,
'global_merge_vars' => array(
array(
'unsub' => 'unsub'
)
),
);
What step am I missing?
TIA!
The problem was the URL was missing a slash (http:/mydomain...)
This was caused by TinyMCE converting URLs. I added convert_urls: false to the tinymce.init and that solved my problem.
Kudos to Mandrill Support for helping me identify the problem.

How to get contact list from yahoo in rails using OAuth

I can successfully get the contacts from google using OAuth gem in rails. my gmail configuration is :
:google=>{
:key=>"***",
:secret=>"***",
:expose => true,
:scope=>"https://www.google.com/m8/feeds/"
}
now i want to get contact from yahoo and hot mail. How to get that contact I have given following configuration in my oauth_consumer.rb file
:yahoo=>{
:client=>:oauth_gem,
:expose => true,
:allow_login => true,
:key=>"**",
:secret=>"**",
:scope=>"https://me.yahoo.com"
}
:hotmail=>{
:client=>:oauth_gem,
:expose => true,
:allow_login => true,
:key=>"**",
:secret=>"**"
}
when i am trying to do same like what is done in google it gives error like undefined methoddowncase' for nil:NilClass`
I have also tried contacts gem but fail to load contacts.
Please try to use OmniContacts https://github.com/Diego81/omnicontacts this will help you alot.
In your gemfile
gem "omnicontacts"
Create config/initializers/omnicontacts.rb
require "omnicontacts"
Rails.application.middleware.use OmniContacts::Builder do
importer :gmail, "client_id", "client_secret", {:redirect_path => "/oauth2callback", :ssl_ca_file => "/etc/ssl/certs/curl-ca-bundle.crt"}
importer :yahoo, "consumer_id", "consumer_secret", {:callback_path => '/callback'}
importer :hotmail, "client_id", "client_secret"
importer :facebook, "client_id", "client_secret"
end
Create an app to yahoo https://developer.apps.yahoo.com/projects
This will ask to verify your domain. So, just change your domain of localhost:3000 to local.appname.com:3000 or prefer your live server... (change host in local --- sudo gedit /etc/hosts)
in your controller
#contacts = request.env['omnicontacts.contacts']
#user = request.env['omnicontacts.user']
puts "List of contacts of #{user[:name]} obtained from #{params[:importer]}:"
#contacts.each do |contact|
puts "Contact found: name => #{contact[:name]}, email => #{contact[:email]}"
end