来自PHP数据库(PDO)的MySQL数据库的自动填充数据(输入字段)(Auto fill-in data (input field) from MySQL Database in PHP (PDO))
这篇文章包含:
- 3个PHP页面
- MySQL表图片
- 表格的图片
正如标题所说,我需要从我的数据库中 提取一些信息 。
到目前为止,我有以下内容:
索引页 < - 您需要使用个人代码登录此处。 (这是我从联系页面上获得的“会话用户名”)
配置页 < - 用于数据库访问和所有
联系页面 < - 在这里我想自动填写用户数据。
数据库表包括:
- 用户名; 电子邮件; realName(以及其他一些我不需要的东西)
所以在联系页面中我想看到以下内容:
卡号=用户名(这已经有效)
自动填写:realName和电子邮件根据用户名。
也许有可能在登录时提取信息并将其存储在POST变量中? 但是怎么样?
数据库:
- 表我需要使用: '成员'
用户自己给出的信息= 用户名
我需要自动填写的信息= realName和email
表格的图片。
电子邮件应该在SESSION语句中,因此我可以向该人发送确认电子邮件,并且应该从数据库输入realName。
这些是当前运行的文件:
config.php文件:
<?php ob_start(); session_start(); //set timezone date_default_timezone_set('Europe/Brussels'); //database credentials define('DBHOST','*****'); define('DBUSER','*****'); define('DBPASS','*****'); define('DBNAME','*****'); //application address define('DIR','http://*****/'); define('SITEEMAIL','noreply@*****'); try { //create PDO connection $db = new PDO("mysql:host=".DBHOST.";dbname=".DBNAME, DBUSER, DBPASS); $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); } catch(PDOException $e) { //show error echo '<p class="bg-danger">'.$e->getMessage().'</p>'; exit; } //include the user class, pass in the database connection include('classes/user.php'); include('classes/phpmailer/mail.php'); $user = new User($db); ?>
联系表:
<?php require('includes/config.php'); //if not logged in redirect to login page if(!$user->is_logged_in()){ header('Location: index.php'); } ?> <html> <head> <title>*****</title> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1" /> <!--[if lte IE 8]><script src="siteassets/assets/js/ie/shiv.js"></script><![endif]--> <link rel="stylesheet" href="siteassets/assets/css/main.css" /> <!--[if lte IE 8]><link rel="stylesheet" href="siteassets/assets/css/ie8.css" /><![endif]--> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.2/jquery.min.js"></script> <script> $(document).ready(function(){ $('#next').keyup(calculate); $('#nextprice').keyup(calculate); $('#current').keyup(calculate); $('#currentprice').keyup(calculate); }); function calculate(e) { $('#total').val($('#next').val() * $('#nextprice').val() + $('#current').val() * $('#currentprice').val()); } </script> </head> <body class="landing"> <div id="page-wrapper"> <!-- Header --> <header id="header" class="alt"> <nav id="nav"> <ul> <li> <a href="#" class="icon fa-angle-down">Menu</a> <ul> <li><a href="home.php">Current Project</a></li> <li><a href="newproj.php">Next Projects</a></li> <li><a href="prev.php">Previous Projects</a></li> <li><a href="who.php">Who are we?</a></li> </ul> </li> <li><a href="contact.php" class="button">contact</a></li> <li><a href='logout.php'>Logout</a></li> </ul> </nav> </header> <!-- Banner --> <section id="banner"> <h2>*****</h2> <p>Slogan.</p> <ul class="actions"> <li><a href="home.php" class="button">Current Project</a></li> <li><a href="newproj.php" class="button">Next Projects</a></li> <li><a href="prev.php" class="button">Previous Projects</a></li> <li><a href="who.php" class="button">Who are we?</a></li> <li><a href="contact.php" class="button special">contact</a></li> </ul> </section> <!-- Main --> <section id="main" class="container 75%"> <div class="box"> <? if($_SERVER['REQUEST_METHOD']=="POST") { if(strlen($_POST['name2']) == 0) { $error_msg ="- Please, provide us with your name.<br>"; } if(!empty($error_msg)) { //Een van de velden werd niet goed ingevuld echo "<b>Your message can't be send due to the following reason:</b> <br><br>"; echo $error_msg; echo "<br>Click on <a href='javascript:history.back(1)'>Go back</a> and provide us with your name.<br><br>"; } else { $recipient = "*****"; $subject = "******"; $header = "From: " . $_POST['uwemail'] . "\n"; $mail_body = "Contact script werd op " . date("d-m-Y") . " om " . date("H:i") . " uur uitgevoerd.\n"; $mail_body .= "*****:\n\n"; $mail_body .= "Naam: " . $_POST['name2'] . "\n"; $mail_body .= "Met als kaartnummer: " . $_POST['card2'] . "\n"; $mail_body .= "******: " . $_POST['current2'] . "\n"; $mail_body .= "******: " . $_POST['next2'] . "\n"; $mail_body .= "Voor een totaal van: " . $_POST['total2'] . " EUR."; $mail_body .= "\n\n -- ****** --"; mail($recipient, $subject, $mail_body, $header); print "<b>IMPORTANT!</b>"; print "<br><br>*****."; print "<br><br>***** "; print $_POST['total2']; print " *****"; print "<br><br>******."; print "<br><br>******"; } } else { ?> <form action="<? echo $_SERVER['PHP_SELF']; ?>" method="POST" name="contact"> <div class="row uniform 50%"> <div class="6u 12u(mobilep)"> Your personal card number <input type="text" name="card2" id="card" value="<?php echo $_SESSION['username']; ?>" placeholder="Card Number" readonly/> </div> <div class="6u 12u(mobilep)"> Please enter your name. (mandatory) <input type="text" name="name2" id="name" value="" placeholder="Your name" /> </div> </div> <div class="row uniform 50%"> <div class="6u 12u(mobilep)"> Current Project - Smile <input type="text" name="current2" id="current" value="" placeholder="How many tickets would you like?" /> </div> <div class="6u 12u(mobilep)"> Next Project - Sand <input type="text" name="next2" id="next" value="" placeholder="How many tickets would you like?" /> </div> </div> <div class="row uniform 50%"> <div class="6u 12u(mobilep)"> <input type="hidden" id="currentprice" value="10" /> </div> <div class="6u 12u(mobilep)"> <input type="hidden" id="nextprice" value="10" placeholder="" /> </div> </div> <div class="6u 12u(mobile)"> <input name="uwemail" placeholder="Email" type="hidden" value="******"/> </div> <div class="6u 12u(mobilep)"> Total price.(In EUR) <input type="text" name="total2" id="total" value="" readonly/> </div> </div> <div class="row uniform"> <div class="12u"> <ul class="actions align-center"> <li><input type="submit" name="submit"value="Place Order"/></li> </ul> </div> </div> </form> <?php } ?> </div> </section> <!-- Footer --> <footer id="footer"> <ul class="copyright"> <li>© *****. All rights reserved.</li> </ul> </footer> </div> <!-- Scripts --> <script src="siteassets/assets/js/jquery.min.js"></script> <script src="siteassets/assets/js/jquery.dropotron.min.js"></script> <script src="siteassets/assets/js/jquery.scrollgress.min.js"></script> <script src="siteassets/assets/js/skel.min.js"></script> <script src="siteassets/assets/js/util.js"></script> <!--[if lte IE 8]><script src="siteassets/assets/js/ie/respond.min.js"></script><![endif]--> <script src="siteassets/assets/js/main.js"></script> </body> </html>
索引页面(他们必须登录)
<?php //include config require_once('includes/config.php'); //process login form if submitted if(isset($_POST['submit'])){ $username = $_POST['username']; $password = $_POST['password']; if($user->login($username,$password)){ $_SESSION['username'] = $username; header('Location: home.php'); exit; } else { $error[] = 'Wrong username or password or your account has not been activated.'; } }//end if submit ?> <html> <head> <title>******</title> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1" /> <!--[if lte IE 8]><script src="assets/js/iv.js"></script><! [endif]--> <link rel="stylesheet" href="assets/css/main.css" /> <!--[if lte IE 9]><link rel="stylesheet" href="assets/css/ie9.css" /><![endif]--> <!--[if lte IE 8]><link rel="stylesheet" href="assets/css/ie8.css" /><![endif]--> <noscript><link rel="stylesheet" href="assets/css/noscript.css" /> </noscript> </head> <body class="is-loading"> <!-- Wrapper --> <div id="wrapper"> <!-- Main --> <section id="main"> <header> <h1>*****</h1> <h1><a style="color:#FFFFFF" href=''>Coming soon.</a></h1> <div class="container"> <div class="row"> <div class="col-xs-12 col-sm-8 col-md-6 col-sm-offset-2 col-md-offset-3"> <form role="form" method="post" action="" autocomplete="off"> <h2>Please Login</h2> <hr> <?php //check for any errors if(isset($error)){ foreach($error as $error){ echo '<p class="bg-danger">'.$error.'</p>'; } } if(isset($_GET['action'])){ //check the action switch ($_GET['action']) { case 'active': echo "<h2 class='bg-success'>Your account is now active you may now log in.</h2>"; break; case 'reset': echo "<h2 class='bg-success'>Please contact us for a new card.</h2>"; break; case 'resetAccount': echo "<h2 class='bg-success'>Password changed, you may now login.</h2>"; break; } } ?> <div class="form-group"> <input type="text" name="username" id="username" class="form-control input-lg" placeholder="Enter your card number" value=" <?php if(isset($error)){ echo $_POST['username']; } ?>" tabindex="1"> </div> <div class="form-group"> <input type="hidden" name="password" id="password" class="form-control input-lg" value="*****" tabindex="3" > </div> <br> <div class="row"> <div class="col-xs-6 col-md-6"><input type="submit" name="submit" value="Login" class="btn btn-primary btn-block btn-lg" tabindex="5"></div> </div> <hr> <div class="row"> <div class="col-xs-9 col-sm-9 col-md-9"> <a style="color:#FFFFFF" href='*********'>Lost your card? Contact us.</a> </div> </div> </form> </div> </div> </div> </header> </section> <!-- Footer --> <footer id="footer"> <ul class="copyright"> <li>© ******</li> </ul> </footer> </div> <!-- Scripts --> <!--[if lte IE 8]><script src="assets/js/respond.min.js"> </script><![endif]--> <script> if ('addEventListener' in window) { window.addEventListener('load', function() { document.body.className = document.body.className.replace(/\bis-loading\b/, ''); }); document.body.className += (navigator.userAgent.match(/(MSIE|rv:11\.0)/) ? ' is-ie' : ''); } </script> </body> </html>
This post contains:
- 3 PHP pages
- MySQL table picture
- Picture of the form
As the title says, I need to extract some information from my database.
So far I have the following:
Index page <-- You need to login here with a personal code. (this is where I get the 'Session username' from that already works at the contact page)
Config page <-- Used for database access and all
Contact page <-- In here I would like to auto fill-in the users data.
Database table consists of:
- username; email; realName (and some other stuff I don't need here)
So in the contact page I would like to see the following:
Card number = username (this already works)
Auto fill-in: realName and email according to the username.
Maybe it is possible to extract the info when logging in and storing these in the POST variable already? But how?
Database:
- Table I need to use: 'members'
The info given by the user himself/herself = username
The info I need to auto fill-in = realName and email
Picture of the form.
The email should be in the SESSION statement, so I can send a confirmation email to the person, and the realName should be entered from the database.
These are the files currently running:
config.php:
<?php ob_start(); session_start(); //set timezone date_default_timezone_set('Europe/Brussels'); //database credentials define('DBHOST','*****'); define('DBUSER','*****'); define('DBPASS','*****'); define('DBNAME','*****'); //application address define('DIR','http://*****/'); define('SITEEMAIL','noreply@*****'); try { //create PDO connection $db = new PDO("mysql:host=".DBHOST.";dbname=".DBNAME, DBUSER, DBPASS); $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); } catch(PDOException $e) { //show error echo '<p class="bg-danger">'.$e->getMessage().'</p>'; exit; } //include the user class, pass in the database connection include('classes/user.php'); include('classes/phpmailer/mail.php'); $user = new User($db); ?>
contact form:
<?php require('includes/config.php'); //if not logged in redirect to login page if(!$user->is_logged_in()){ header('Location: index.php'); } ?> <html> <head> <title>*****</title> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1" /> <!--[if lte IE 8]><script src="siteassets/assets/js/ie/shiv.js"></script><![endif]--> <link rel="stylesheet" href="siteassets/assets/css/main.css" /> <!--[if lte IE 8]><link rel="stylesheet" href="siteassets/assets/css/ie8.css" /><![endif]--> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.2/jquery.min.js"></script> <script> $(document).ready(function(){ $('#next').keyup(calculate); $('#nextprice').keyup(calculate); $('#current').keyup(calculate); $('#currentprice').keyup(calculate); }); function calculate(e) { $('#total').val($('#next').val() * $('#nextprice').val() + $('#current').val() * $('#currentprice').val()); } </script> </head> <body class="landing"> <div id="page-wrapper"> <!-- Header --> <header id="header" class="alt"> <nav id="nav"> <ul> <li> <a href="#" class="icon fa-angle-down">Menu</a> <ul> <li><a href="home.php">Current Project</a></li> <li><a href="newproj.php">Next Projects</a></li> <li><a href="prev.php">Previous Projects</a></li> <li><a href="who.php">Who are we?</a></li> </ul> </li> <li><a href="contact.php" class="button">contact</a></li> <li><a href='logout.php'>Logout</a></li> </ul> </nav> </header> <!-- Banner --> <section id="banner"> <h2>*****</h2> <p>Slogan.</p> <ul class="actions"> <li><a href="home.php" class="button">Current Project</a></li> <li><a href="newproj.php" class="button">Next Projects</a></li> <li><a href="prev.php" class="button">Previous Projects</a></li> <li><a href="who.php" class="button">Who are we?</a></li> <li><a href="contact.php" class="button special">contact</a></li> </ul> </section> <!-- Main --> <section id="main" class="container 75%"> <div class="box"> <? if($_SERVER['REQUEST_METHOD']=="POST") { if(strlen($_POST['name2']) == 0) { $error_msg ="- Please, provide us with your name.<br>"; } if(!empty($error_msg)) { //Een van de velden werd niet goed ingevuld echo "<b>Your message can't be send due to the following reason:</b> <br><br>"; echo $error_msg; echo "<br>Click on <a href='javascript:history.back(1)'>Go back</a> and provide us with your name.<br><br>"; } else { $recipient = "*****"; $subject = "******"; $header = "From: " . $_POST['uwemail'] . "\n"; $mail_body = "Contact script werd op " . date("d-m-Y") . " om " . date("H:i") . " uur uitgevoerd.\n"; $mail_body .= "*****:\n\n"; $mail_body .= "Naam: " . $_POST['name2'] . "\n"; $mail_body .= "Met als kaartnummer: " . $_POST['card2'] . "\n"; $mail_body .= "******: " . $_POST['current2'] . "\n"; $mail_body .= "******: " . $_POST['next2'] . "\n"; $mail_body .= "Voor een totaal van: " . $_POST['total2'] . " EUR."; $mail_body .= "\n\n -- ****** --"; mail($recipient, $subject, $mail_body, $header); print "<b>IMPORTANT!</b>"; print "<br><br>*****."; print "<br><br>***** "; print $_POST['total2']; print " *****"; print "<br><br>******."; print "<br><br>******"; } } else { ?> <form action="<? echo $_SERVER['PHP_SELF']; ?>" method="POST" name="contact"> <div class="row uniform 50%"> <div class="6u 12u(mobilep)"> Your personal card number <input type="text" name="card2" id="card" value="<?php echo $_SESSION['username']; ?>" placeholder="Card Number" readonly/> </div> <div class="6u 12u(mobilep)"> Please enter your name. (mandatory) <input type="text" name="name2" id="name" value="" placeholder="Your name" /> </div> </div> <div class="row uniform 50%"> <div class="6u 12u(mobilep)"> Current Project - Smile <input type="text" name="current2" id="current" value="" placeholder="How many tickets would you like?" /> </div> <div class="6u 12u(mobilep)"> Next Project - Sand <input type="text" name="next2" id="next" value="" placeholder="How many tickets would you like?" /> </div> </div> <div class="row uniform 50%"> <div class="6u 12u(mobilep)"> <input type="hidden" id="currentprice" value="10" /> </div> <div class="6u 12u(mobilep)"> <input type="hidden" id="nextprice" value="10" placeholder="" /> </div> </div> <div class="6u 12u(mobile)"> <input name="uwemail" placeholder="Email" type="hidden" value="******"/> </div> <div class="6u 12u(mobilep)"> Total price.(In EUR) <input type="text" name="total2" id="total" value="" readonly/> </div> </div> <div class="row uniform"> <div class="12u"> <ul class="actions align-center"> <li><input type="submit" name="submit"value="Place Order"/></li> </ul> </div> </div> </form> <?php } ?> </div> </section> <!-- Footer --> <footer id="footer"> <ul class="copyright"> <li>© *****. All rights reserved.</li> </ul> </footer> </div> <!-- Scripts --> <script src="siteassets/assets/js/jquery.min.js"></script> <script src="siteassets/assets/js/jquery.dropotron.min.js"></script> <script src="siteassets/assets/js/jquery.scrollgress.min.js"></script> <script src="siteassets/assets/js/skel.min.js"></script> <script src="siteassets/assets/js/util.js"></script> <!--[if lte IE 8]><script src="siteassets/assets/js/ie/respond.min.js"></script><![endif]--> <script src="siteassets/assets/js/main.js"></script> </body> </html>
Index page (where they have to login)
<?php //include config require_once('includes/config.php'); //process login form if submitted if(isset($_POST['submit'])){ $username = $_POST['username']; $password = $_POST['password']; if($user->login($username,$password)){ $_SESSION['username'] = $username; header('Location: home.php'); exit; } else { $error[] = 'Wrong username or password or your account has not been activated.'; } }//end if submit ?> <html> <head> <title>******</title> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1" /> <!--[if lte IE 8]><script src="assets/js/iv.js"></script><! [endif]--> <link rel="stylesheet" href="assets/css/main.css" /> <!--[if lte IE 9]><link rel="stylesheet" href="assets/css/ie9.css" /><![endif]--> <!--[if lte IE 8]><link rel="stylesheet" href="assets/css/ie8.css" /><![endif]--> <noscript><link rel="stylesheet" href="assets/css/noscript.css" /> </noscript> </head> <body class="is-loading"> <!-- Wrapper --> <div id="wrapper"> <!-- Main --> <section id="main"> <header> <h1>*****</h1> <h1><a style="color:#FFFFFF" href=''>Coming soon.</a></h1> <div class="container"> <div class="row"> <div class="col-xs-12 col-sm-8 col-md-6 col-sm-offset-2 col-md-offset-3"> <form role="form" method="post" action="" autocomplete="off"> <h2>Please Login</h2> <hr> <?php //check for any errors if(isset($error)){ foreach($error as $error){ echo '<p class="bg-danger">'.$error.'</p>'; } } if(isset($_GET['action'])){ //check the action switch ($_GET['action']) { case 'active': echo "<h2 class='bg-success'>Your account is now active you may now log in.</h2>"; break; case 'reset': echo "<h2 class='bg-success'>Please contact us for a new card.</h2>"; break; case 'resetAccount': echo "<h2 class='bg-success'>Password changed, you may now login.</h2>"; break; } } ?> <div class="form-group"> <input type="text" name="username" id="username" class="form-control input-lg" placeholder="Enter your card number" value=" <?php if(isset($error)){ echo $_POST['username']; } ?>" tabindex="1"> </div> <div class="form-group"> <input type="hidden" name="password" id="password" class="form-control input-lg" value="*****" tabindex="3" > </div> <br> <div class="row"> <div class="col-xs-6 col-md-6"><input type="submit" name="submit" value="Login" class="btn btn-primary btn-block btn-lg" tabindex="5"></div> </div> <hr> <div class="row"> <div class="col-xs-9 col-sm-9 col-md-9"> <a style="color:#FFFFFF" href='*********'>Lost your card? Contact us.</a> </div> </div> </form> </div> </div> </div> </header> </section> <!-- Footer --> <footer id="footer"> <ul class="copyright"> <li>© ******</li> </ul> </footer> </div> <!-- Scripts --> <!--[if lte IE 8]><script src="assets/js/respond.min.js"> </script><![endif]--> <script> if ('addEventListener' in window) { window.addEventListener('load', function() { document.body.className = document.body.className.replace(/\bis-loading\b/, ''); }); document.body.className += (navigator.userAgent.match(/(MSIE|rv:11\.0)/) ? ' is-ie' : ''); } </script> </body> </html>
原文:
最满意答案
在这里回答我自己的问题。 此问题是由mysql2 gem版本(0.3.18)与gemfile(0.3.16)中指定的版本不匹配引起的。
Answering my own question here. This problem was caused by a mismatch between the mysql2 gem version (0.3.18) and the version specified in the gemfile (0.3.16).
相关问答
更多-
我有同样的问题,我通过创建一个环境变量来解决它,每当我登录到生产服务器,并制作一个微型指南的步骤来配置它: https://gist.github.com/pablosalgadom/4d75f30517edc6230a67 我正在使用Rails 4.1与Unicorn v4.8.2,当我尝试部署我的应用程序,它没有正确启动,在unicorn.log文件中,我发现这个错误消息: app error: Missing `secret_key_base` for 'production' environment ...
-
Ruby on Rails和Rake问题:未初始化的常数Rake :: DSL(Ruby on Rails and Rake problems: uninitialized constant Rake::DSL)[2023-06-21]
DHH的一个推文 。 Rake .9.0打破了Rails和其他几件事情,你需要: gem "rake", "0.8.7" 在你的宝石文件。 A tweet from DHH earlier. Rake .9.0 breaks Rails and several other things, you need to: gem "rake", "0.8.7" in your Gemfile. -
Rake db:迁移问题(Rake db:migrate issue)[2021-07-08]
看到了 Rake 0.9.0有一个问题。 现在在您的Gemfile中使用0.8.7。 See that There's an issue with Rake 0.9.0. Use 0.8.7 in your Gemfile for now. -
rails 3.2.9的rake错误(rake error with rails 3.2.9)[2023-12-03]
您是否可能忘记更新某些依赖项? 尝试运行: $ bundle outdated 并检查是否需要更新其他宝石.... Is it possible that you forgot to update some dependencies? Try to run: $ bundle outdated and check if you need to update other gems.... -
如果我将gem'rdoc'添加到我的gem文件中,错误似乎就消失了。 我不确定为什么这会有任何区别,因为它已经是另一个宝石的依赖 The error seems to go away if I add gem 'rdoc' to my gem file. I am not sure why this makes any difference, because it was already a dependency of another gem
-
感谢Carl Smotricz的暗示! 我终于解决了这个问题:cron使用的环境变量可能与用户环境变量不同......我的crond服务使用us-ascii编码,而我的rake任务使用utf-8就是这种情况。 要解决这个问题,我只需要通过在我的crond文件中添加以下行来更改crond的编码(在我的centos5中,它位于:/ var / spool / cron / root) SHELL=/bin/bash LANG=en_US.UTF-8 LANGUAGE=en LC_CTYPE=en_US.UTF- ...
-
尝试使用gem update --system更新RubyGems(Ruby 2.0上有RubyGems 1.8.x的bug) Try updating RubyGems with gem update --system (there's a bug with RubyGems 1.8.x on Ruby 2.0)
-
Rails 4.0.0,Gemfile需要rake 10.1.0 for Rake(Rails 4.0.0, Gemfile requires rake 10.1.0 for Rake)[2022-01-14]
像它建议的那样,你可以做bundle exec rake db:migrate 对于不需要添加前缀的解决方案,请尝试执行bundle update rake Like it suggests, you can do bundle exec rake db:migrate For a solution that wouldn't require adding the prefix, try doing bundle update rake -
在这里回答我自己的问题。 此问题是由mysql2 gem版本(0.3.18)与gemfile(0.3.16)中指定的版本不匹配引起的。 Answering my own question here. This problem was caused by a mismatch between the mysql2 gem version (0.3.18) and the version specified in the gemfile (0.3.16).
-
尝试添加环境,这将具有加载rails应用程序的效果。 task :scrape_info => :environment do ... end Try adding the environment, this will have the effect of loading your rails app. task :scrape_info => :environment do ... end